On Tue, Aug 2, 2011 at 5:53 PM, Chris Rebert <c...@rebertia.com> wrote:
> If you /really/ need a sorted mapping datatype, google for > "sorteddict" (which is quite distinct from OrderedDict). > Or look for a binary search tree or skip list implementation of some > sort; but these aren't commonly used in Python, so it may be hard to > find a good one. > The blist package (I'm the author) provides a list-like type that has O(log n) insertions and deletions. It provides a sorteddict type that uses the blist type under-the-hood. blist's "sorteddict" supports the "key" parameter (which works like list.sort's key parameter), which the original poster could use to maintain the keys in reverse order. http://pypi.python.org/pypi/blist/ There's no overhead to learn how to use the new types. A blist works exactly like a list but with different performance characteristics, and a sorteddict works just like a dict but keeps the keys sorted. -- Daniel Stutzbach
-- http://mail.python.org/mailman/listinfo/python-list