[Python-ideas] `OrderedDict.sort`

Stephen J. Turnbull stephen at xemacs.org
Wed Sep 25 06:27:08 CEST 2013

Andrew Barnert writes:

 > See http://stupidpythonideas.blogspot.com/2013/07/sorted-collections-in-stdlib.html,
 > which I wrote one or two iterations ago to collect all of the
 > issues, and please let me know if I missed any or you have anything
 > to add.

A small nit: SortedSequence and SortedDicts should be mappings,
guaranteeing "fast" (preferably O(1)) access for any key (integral and
arbitrary, respectively).  Therefore, in the case of a SortedDict the
user should be no more surprised at a complaint about hashability than
they should be in the case of a dict (especially considering the name!)

I'll grant that some users might be perfectly happy with O(log N)
"reasonably fast" access, but others would not be pleased.

More information about the Python-ideas mailing list