sorteddict [was a PEP proposal, but isn't anymore!]
Hamilton, William
whamil1 at entergy.com
Mon Oct 1 08:24:57 EDT 2007
> From: thebjorn
> What's stabledict? I'm assuming that ordereddict is a mapping that
> maintains insertion order(?)
Yes, ordereddict is a dict that maintains insertion order. Stabledict
is probably a dict that maintains _an_ order, so that repr() and the
like return the same value when used on dicts containing the same data.
> In the Smalltalk collection hierarchy SortedCollection is a subclass
> of OrderedCollection, which implies to me that it'd be better to add
> an ordereddict first.
That depends entirely on how ordereddict and sorteddict function. If
they are similar there might be a benefit. However, an ordereddict
would probably be best implemented with an internal list of keys,
whereas the consensus seems to be using a tree for sorteddict. In this
case, trying to build sorteddict from ordereddict is going to give you
extra baggage and overhead for no benefit.
--
-Bill Hamilton
More information about the Python-list
mailing list