Why are there no ordered dictionaries?

Alex Martelli aleax at mail.comcast.net
Tue Nov 22 22:12:07 EST 2005


Tom Anderson <twic at urchin.earth.li> wrote:
   ...
> > have a certain order that is preserved). Those who suggested that the
> > "sorted" function would be helpful probably thought of a "sorted 
> > dictionary" rather than an "ordered dictionary."
> 
> Exactly.
> 
> Python could also do with a sorted dict, like binary tree or something,
> but that's another story.

However, since Christoph himself just misclassified C++'s std::map as
"ordered" (it would be "sorted" in this new terminology he's now
introducing), it seems obvious that the terminological confusion is
rife.  Many requests and offers in the past for "ordered dictionaries"
(e.g. on this group) were also "sorted", NOT "ordered", in this new
terminology.

Maybe it would therefore be clearer to have the name of the new
container reflect this, with a specific mention of *insertion* order...
rather than just call it "ordered" and risk probable confusion.


Alex



More information about the Python-list mailing list