Why are there no ordered dictionaries?

Carsten Haese carsten at uniqsys.com
Tue Nov 22 14:17:13 EST 2005


On Tue, 2005-11-22 at 13:37, Christoph Zwerschke wrote:
> Would the default semantics below really be that suprising?
> 
> "An ordered dictionary remembers the order in which keys are first seen 
> [...] Overwriting an entry replaces 
> its value, but does not affect its position in the key order. Removing 
> an entry (using 'del') _does_ remove it from the key order. Accordingly, 
> if the entry is later recreated, it will then occur last in the key 
> order. [...]"

> I can't help but I still find it unambiguous and intuitive enough to 
> consider it "the one" standard implementation for ordered dictionaries.

I don't think it's intuitive if you can't describe it without
contradicting yourself. If the order of the keys really were the order
in which they were first seen by the dictionary, deleting and recreating
a key should maintain its original position.

-Carsten





More information about the Python-list mailing list