[Python-Dev] PEP 372 -- Adding an ordered directory to collections ready for pronouncement
Lie Ryan
lie.1296 at gmail.com
Wed Mar 4 15:02:46 CET 2009
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?
More information about the Python-Dev
mailing list