[Python-ideas] OrderedDict.peekitem()

Andrew Barnert abarnert at yahoo.com
Tue Jul 7 14:14:00 CEST 2015


On Jul 6, 2015, at 21:27, Neil Girdhar <mistersheik at gmail.com> wrote:
> 
>> On Tue, Jul 7, 2015 at 12:08 AM, Andrew Barnert <abarnert at yahoo.com> wrote:
>>> On Jul 6, 2015, at 14:30, Neil Girdhar <mistersheik at gmail.com> wrote:
>>> 
>>> SortedDict (http://www.grantjenks.com/docs/sortedcontainers/sorteddict.html) manages to support indexing.  
>> 
>> Only by having a special view, accessed as .index. If it just took indices as subscripts, that would be ambiguous with integer keys.
>> 
>>> Can OrderedDict do the same thing?
>> 
>> It's worth noting that most of the various different sorted containers on PyPI support something equivalent, but all with different interfaces.
> 
> 2015 might not be the right year to add sorted containers to Python.  However, it might be a good idea to standardize the interface of a "sorted map" and "sorted set" in a PEP.

I suggested that before, but apparently 2013 was not the right time to suggest standardizing the interface without adding an implementation to the stdlib; maybe things are different enough in 2015. Thanks for raising the idea. I'll go back and try to dig up other past proposals and re-survey the different options to see if that seems plausible, and meanwhile I'll stop derailing this thread with it. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150707/4d4b10fd/attachment.html>


More information about the Python-ideas mailing list