An ordered dictionary for the Python library?

Mark Summerfield m.n.summerfield at googlemail.com
Fri Sep 14 16:00:45 EDT 2007


On 14 Sep, 20:25, James Stroud <jstr... at mbi.ucla.edu> wrote:
> Mark Summerfield wrote:
[snip]
> May I also make one more suggestion, to call it a "sort_ordered_dict"
> (or "sortordereddict", or even better a "sorteddict"--where the "ed"
> comes from "ordered")? Its hard for me to move past the established
> definition of "order", as we think of tuples being ordered--as in the
> first sentence ofhttp://en.wikipedia.org/wiki/Tuple--tosomething that
> is preserving an order according to a comparison. The distinction is so
> firmly ingrained in my head that it took me a while to wake up to the
> fact that you were describing something completely different than an
> ordered dictionary (e.g.http://www.voidspace.org.uk/python/odict.html)
> even though you were being very unambiguous with your description.
>
> And I also think the ability to drop it in for a built-in dict is very
> valuable.
>
> James

It seems that the correct Python terminology for this is indeed
sorteddict (ordered by key), with ordereddict meaning (in insertion
order).

I guess I'll have to rename my module (although unfortunately, my book
has just gone into production and I have a (simpler) example of what I
considered to be an ordered dict, so I will be adding to the
terminology confusion). That notwithstanding, given that it is a
sorteddict, how is the API?




More information about the Python-list mailing list