Why are there no ordered dictionaries?

Antoon Pardon apardon at forel.vub.ac.be
Mon Nov 21 05:04:26 EST 2005


Op 2005-11-21, Christoph Zwerschke schreef <cito at online.de>:
> bonono at gmail.com wrote:
>> Personally, I have needs for ordered dict but I don't think it should
>> be in standard library though, as different situation called for
>> different behaviour for "ordered" and skewing my code to a standard lib
>> way is no good.
>
> I have started the thread in the first place because I believed it is 
> pretty unabmiguous what an "ordered dictionary" is and how it should 
> behave. That's why I asked myself why something that straigthforward has 
> not been added to the standard lib yet. Maybe I'm wrong; I must admit 
> that I haven't meditated about it very much.

Well it doesn't seem that obvious, because the two recipes you have
gotten, do something different from what I understand as an ordered
dictionary.

The two recipes order the keys by insertion order.

My idea would have been that some order was defined
on your keys in advance and that when you iterated over
the dictionary, the results would be ordered in sequence
of key order.

> Do you have an example for different options of behavior?

Well you have two above. Maybe someone can think of something
else.

Which behaviour are you looking for?

-- 
Antoon Pardon



More information about the Python-list mailing list