Ordered dictionaries?

Courageous jkraska at san.rr.com
Thu Dec 13 19:14:57 EST 2001

>> One last Perl module that I need to replace to
>> complete my Python toolkit is a custom module that let
>> me create a dictionary whose keys were settable and
>> retrievable in a particular order.  Essentially, this
>> let us have a list whose ordered elements were also
>> accessible by name.

What you are looking for is a tree of some kind. Any variety
of tree will due, although once statistical amortization and
constant costs are taken into account, Red Black Trees are
widely-regarded as superior. IIRC, there already exists several
trees in the Vaults of Parnassus, including a Red Black Tree.

For Python, any variety of ordered, searchable tree will due.
Any of the complexity costs will be masked by the Python
interpreter itself for any sane value of N < 1000.


More information about the Python-list mailing list