Nick Coghlan wrote:
Lie Ryan wrote:
How about making odict ordered by insertion order, then provide an
optional argument for defining sorter? This optional argument must be a
function/lambda/callable object and must be the first argument.
or better yet, in the spirit of dumping cmp comparison like in list, the
first optional argument would be a function that returns the sorting key
of the object. If the optional argument is not specified, the current
ordereddict semantic (by insertion order) will be used.
As the PEP mentions (and Hrvoje brought up again already in this
thread), a hash table (i.e. dict) probably isn't the right data
structure to use as the basis for an "always sorted" container.
In-memory databases, balanced trees, etc, etc.
Isn't ordered dictionary essentially also an "always sorted" container?
It is always sorted depending on the order of insertion? I can't see any
technical reason why the data structure can't accommodate them both. Can
you point me to a discussion on this?
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com