[Python-ideas] ordered dict (original) (raw)

BJörn Lindqvist bjourne at gmail.com
Sat Apr 21 06:28:18 CEST 2007


On 4/20/07, Terry Reedy <tjreedy at udel.edu> wrote:

2. Order in the sorting or collation sense, which I presume you mean. To reduce confusion, call this a sorted dictionary, as others have done.

Regardless, this has the problem that potential keys are not always comparable. This will become worse when most cross-type comparisons are disallowed in 3.0. So pershaps the init method should require a tuple of allowed key types.

l = [(), "moo", 123, []] l.sort() l [123, [], 'moo', ()]

If it is not a problem for lists it is not a problem for ordered dictionaries.

If not already present in PyPI, someone could code an implementation and add it there. When such has be tested and achieved enough usage, then it might be proposed for addition to the collections module.

And that is how the currently considered for Python 3.0 ordered dict implementation got into Python?

I find it amusing that over the years people have argued against having an ordered dict in Python. But now, when one is considered, only THAT version with THOSE semantics, is good. The rest should go to PyPI.

-- mvh Björn



More information about the Python-ideas mailing list