Why are there no ordered dictionaries?

Bengt Richter bokr at oz.net
Wed Nov 23 06:45:54 EST 2005


On 23 Nov 2005 01:24:46 -0800, "Kay Schluehr" <kay.schluehr at gmx.net> wrote:

>
>bonono at gmail.com wrote:
>> Steve Holden wrote:
>> > Perhaps now the answer top your question is more obvious: there is by no
>> > means universal agreement on what an "ordered dictionary" should do.
>> > Given the ease with which Python allows you to implement your chosen
>> > functionality it would be presumptuous of the core developers to favour
>> > any one of the several reasonable alternatives that might be chosen.
>> >
>> It seems to be though as "ordered dictionary" are slowly to be confined
>> to only "ordered on order of change to the dictionary".
>
>While I'm only +0 for a standard odict I'm wondering that discussing
>this topic leads to the auctoritative conclusion that it is unsolvable,
>we have to accept infinite diversity etc. where people like me seeing a
>classification immediately ( mathematical education? ) . Of course this
>matter is trivial but we already know about monster-threads revolving
>around decorator syntax ( including hurt souls and semi-scientific
>papers ) and abandoning the print statement in Python 3.0.
>
I think the concept has converged to a replace-or-append-by-key ordering
of key:value items with methods approximately like a dict. We're now
into usability aspects such as syntactic sugar vs essential primitives,
and default behaviour vs selectable modes, ISTM.

E.g., it might be nice to have a mode that assumes d[key] is d.items()[k][1] when
key is an integer, and otherwise uses dict lookup, for cases where the use
case is just string dict keys.

But feature creep is sure a threat to clean design.

Regards,
Bengt Richter



More information about the Python-list mailing list