[Christopher Barker <python...@gmail.com>] > Earlier in the thread, we were pointed to multiple implementations. > > Is this particular one clearly the “best”[*]? > > If so, then sure. > > -CHB > > [*] best meaning “most appropriate for the stdlib”. A couple folks have > already pointed to the quality of the code. But my understanding is that > different algorithms are more or less appropriate for different use > cases. So is this one fairly “universal”?
As noted earlier, SortedContainers is downloaded from PyPI hundreds of thousands of times every day, and that's been so for a long time.. Best I can tell, no similar package is in the same universe as that. The author identified over a dozen potential competitors here[1], but most didn't look like serious projects to him. He ran extensive timing tests against the rest, reported there too. HIs package usually wins, and is at worst competitive. It usually wins on memory burden too. Some of these things are people intrigued by "a data structure" they read about and implement for fun and self-education. That sometimes shines through in data-structure-specific APIs. While the SortedContainers extensive docs explain how things are implemented (if you look in the right spots for that), the API is remarkably agnostic (& useful)). For example, this is a method of SortedList: irange(minimum=None, maximum=None, inclusive=(True, True), reverse=False) which returns an iterator over a contiguous sorted range of values (neither, either, or both of whose endpoints may be included, depending on what you pass for `inclusive` This "makes sense" regardless of how the structure may be implemented. Of course SortedSet and SortedDict support `irange()` too. [1] http://www.grantjenks.com/docs/sortedcontainers/performance.html _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/FD3DSXZUBDUC3PFQH2SS47NIZ36TTOL6/ Code of Conduct: http://python.org/psf/codeofconduct/