Nick posted an excellent answer to this question here:
On Thursday, October 13, 2016 at 4:36:39 PM UTC-4, Марк Коренберг wrote:
> I mean mutable containers that are always sorted when iterating over them.
> See http://bugs.python.org/issue28433
> for example:
> * SortedSet (sorted unique elements, implemented using (rb?)tree instead
> of hash)
> * SortedList (sorted elements, the same as SortedSet, but without
> uniquiness constraint) - actually a (rb?)tree, not a list (i.e. not an
> * SortedDict (sorted by key when interating) - like C++'s ordered_map
> There are many implementations in the net, like:
> and also in pip:
> pip3 search sorted | grep -Ei '[^a-z]sorted'
> I think it should be one standardized implementation of such containers in
> For example, C++ has both ordered_map and unorderd_map.
> Instead of trees, implementation may use SkipList structure, but this is
> just implementation details.
> Such structres imply fast insertion and deletion, ability to iterate, and
> also memory efficiency.
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/