[Python-ideas] Add sorted (ordered) containers

Nick Coghlan ncoghlan at gmail.com
Fri Oct 14 11:23:41 EDT 2016


On 14 October 2016 at 06:48, Neil Girdhar <mistersheik at gmail.com> wrote:
> Related:
>
> Nick posted an excellent answer to this question here:
> http://stackoverflow.com/questions/5953205/why-are-there-no-sorted-containers-in-pythons-standard-libraries

Ah, so this thread is why I've been getting SO notifications for that answer :)

While I think that was a decent answer for its time (as standardising
things too early can inhibit community experimentation - there was
almost 12 years between Twisted's first release in 2002 and asyncio's
provisional inclusion in the standard library in Python 3.4), I also
think the broader context has changed enough that the question may be
worth revisiting for Python 3.7 (in particular, the prospect that it
may be possible to provide this efficiently without having to add a
large new chunk of C code to maintain).

However, given that Grant has already been discussing the possibility
directly with Raymond as the collections module maintainer though,
there's probably not a lot we can add to that discussion here, since
the key trade-off is between:

- helping folks that actually need a sorted container implementation
find one that works well with typical memory architectures in modern
CPUs
- avoiding confusing folks that *don't* need a sorted container with
yet another group of possible data structures to consider in the
standard library

*That* part of my original SO answer hasn't changed, it's just not as
clearcut a decision from a maintainability perspective when we're
talking about efficient and relatively easy to explain pure Python
implementations.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list