Why are there no ordered dictionaries?

Kay Schluehr kay.schluehr at gmx.net
Mon Nov 21 14:53:43 EST 2005


Fredrik Lundh wrote:

> huh?  if you want a list, use a list.
>
>     d = [('a', {...}), ('b', {....})]

If one wants uniform access to a nested data structure like this one
usually starts writing a wrapper class. I do not think the requirement
is anyhow deeper than a standard wrapper around such a list ( as a
model ) but the implementation may be different with respect to optimal
time complexitiy of element access. But the interface of the wrapper
class of d might resemble that of a dict. While the interface is that
of a dict the implementation is closer to a nested list. An "ordered
dict" would lower the impedance between a dict and a list. 

Kay




More information about the Python-list mailing list