Why are there no ordered dictionaries?

Christoph Zwerschke cito at online.de
Fri Nov 25 11:00:33 CET 2005

Fuzzyman wrote:

> That means making keys, values, and items custom objects.
> Creating a new instance would have the overhead of creating 4 new
> objects instead of just 1. Is the added convenience worth it ? (Plus
> the extra layers of method calls for each access).

I'm not sure about that either. But since you are using odict for 
convenience reasons anyway, and not for performance reasons, it would be 
consequential. Performance testing should be made anyway, so this could 
be tested as well. I think that creating these 3 additional objects will 
not matter much if the dict has more than a handful of items. And the 
extra layers will be only called if you really access these keys, values 
or items attributes which will not happen very frequently. Normally, you 
just loop over an ordered directory and acess keyed values.

> I'm not sure. It's a nice idea in terms of using it (we could just
> leave the sequence attribute as an alias for the new keys attribute -
> for backwards compatibility).

Yes, you could make it a deprecated feature.

-- Christoph

More information about the Python-list mailing list