IMO if someone is motivated to get a new container type in Python, a PEP is required.
A PEP has been written for the new removeprefix() and removesuffix() methods which are way simpler ;-)
I expect many questions on corner cases for a sorted container type.
Having a reference implementation, even written in Python, would be helpful.
On Wed, Nov 10, 2021 at 1:00 AM Bob Fang email@example.com wrote:
This is a modest proposal to consider having sorted containers (http://www.grantjenks.com/docs/sortedcontainers/) in standard library. I know that usually adding stuff to standard library requires some strong arguments, so I will try my best to give my reasons here:
- Some mainstream language support them out of box: C++ for example have set/map which are sorted by the key order, and Java has TreeMap which is internally a Red-black tree. I understand languages might target different audiences, but I think Python’s standard library is quite extensive compared to peers. Consider we even have a sqlite driver in the stdlib, I do not think it is outrageous to have sorted containers.
- These containers are not really easy to implement correctly, and usually is out of the scope of day-to-day projects. Especially considering we have a large audience of non-hardcore programmers in Python community. They may have the need to use these structures, but they do not necessarily have the skill/knowledge to implement it.
- Granted, people can just pip install this library, but that is one extra step and less fraction is better for user experience.
- These structures are very useful in competitive programming, I know at least in Leetcode this library is installed for Python.
- The said library is of high implementation quality.
I might be stupid here as I am not the maintainer of this library and I might be not even in a position to submit it to Python as part of stdlib, but here are some of my personal thoughts and would love to hear your opinion!
Python-Dev mailing list -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://firstname.lastname@example.org/message/YB2JD477... Code of Conduct: http://python.org/psf/codeofconduct/