<div dir="ltr"><div><div><div> I'm all for adding more featureful data structures. At the risk of confusing Nick's folks, I think it's possible to do even better than Sorted/Ordered for many collections. In my experience, the simple Ordered trait alone was not enough of a feature improvement over the simpler builtin, leading me to implement an OrderedMultiDict, for instance. Another, more cogent example would be Boltons' IndexedSet: <a href="http://boltons.readthedocs.io/en/latest/setutils.html">http://boltons.readthedocs.io/en/latest/setutils.html</a><br><br></div>It's a normal MutableSet, with almost all the same time complexities, except that you can do indexed_set[0] to get the first-added item, etc. Sometimes it helps to think of it as a kind of UniqueList. If we're going for more featureful containers, I say go all-in!<br><br></div></div>Mahmoud<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 14, 2016 at 8:23 AM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 14 October 2016 at 06:48, Neil Girdhar <<a href="mailto:mistersheik@gmail.com">mistersheik@gmail.com</a>> wrote:<br>
> Related:<br>
><br>
> Nick posted an excellent answer to this question here:<br>
> <a href="http://stackoverflow.com/questions/5953205/why-are-there-no-sorted-containers-in-pythons-standard-libraries" rel="noreferrer" target="_blank">http://stackoverflow.com/<wbr>questions/5953205/why-are-<wbr>there-no-sorted-containers-in-<wbr>pythons-standard-libraries</a><br>
<br>
</span>Ah, so this thread is why I've been getting SO notifications for that answer :)<br>
<br>
While I think that was a decent answer for its time (as standardising<br>
things too early can inhibit community experimentation - there was<br>
almost 12 years between Twisted's first release in 2002 and asyncio's<br>
provisional inclusion in the standard library in Python 3.4), I also<br>
think the broader context has changed enough that the question may be<br>
worth revisiting for Python 3.7 (in particular, the prospect that it<br>
may be possible to provide this efficiently without having to add a<br>
large new chunk of C code to maintain).<br>
<br>
However, given that Grant has already been discussing the possibility<br>
directly with Raymond as the collections module maintainer though,<br>
there's probably not a lot we can add to that discussion here, since<br>
the key trade-off is between:<br>
<br>
- helping folks that actually need a sorted container implementation<br>
find one that works well with typical memory architectures in modern<br>
CPUs<br>
- avoiding confusing folks that *don't* need a sorted container with<br>
yet another group of possible data structures to consider in the<br>
standard library<br>
<br>
*That* part of my original SO answer hasn't changed, it's just not as<br>
clearcut a decision from a maintainability perspective when we're<br>
talking about efficient and relatively easy to explain pure Python<br>
implementations.<br>
<br>
Cheers,<br>
Nick.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Nick Coghlan | <a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a> | Brisbane, Australia<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br></div>