Why are there no ordered dictionaries?
Christoph Zwerschke
cito at online.de
Wed Nov 23 14:38:05 EST 2005
Steve Holden schrieb:
> 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.
The discussion showed indeed that there are some points which are not so
straightforward as I believed. But I still don't see the "several
reasonable alternatives". So far all implementations I have seen are
basically pretty similar. Is there any implementation that is basically
different from Foord/Larosa's odict? I still don't see a principal
problem here, just the problem that the existing implementations are not
well enough thought-out and sophisticated enough.
> 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.
You could say the same about the idea of sets in Python, and it is
probably the reason why it took so much time until they became a part of
Python. I wished that had happened earlier, since sets are "the" basic
mathematic structure. I'm now very happy to have sets not only in the
standard lib but even as built-in types and I'm sure there hasn't been
"universal agreement" on how sets should be implemented either. I don't
think it was presumptuous to finally settle down on one implementation.
Of course, ordered dictionaries are no candidates for becoming built-in
data types, and the existing implementations are not sophisticated and
mature enough to go to the standard lib right now. But principally, if
an improved version is developed (maybe on the occasion of this thread)
and will be tested and proven, why should it not go to the standard lib
some day?
BTW, somebody has suggested it could go to "collections" which sounds
like the right place, but the description says the module is intended
for "High-performance container datatypes", and, as has been discussed,
ordered dictionaries are not used for performance or efficiency reasons,
but rather for reasons of convenience. So *if* they ever go to the
standard lib, I'm not sure whether "collections" would be the right
place. Or collections will need a different description - maybe there
are other interesting basic collection types which are chosen for
convenience, not for performance (for instance, ordered sets)?
-- Christoph
More information about the Python-list
mailing list