Why are there no sorted containers in Python's standard libraries?

后端 未结 6 1011
执念已碎
执念已碎 2020-12-02 18:06

Is there a Python design decision (PEP) that precludes a sorted container from being added to Python?

(OrderedDict is not a sorted container since it is

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 18:37

    There is also the blist module that contains a sortedset data type:

    sortedset(iterable=(), key=None)
    
    >>> from blist import sortedset
    >>> my_set = sortedset([3,7,2,2])
    sortedset([2, 3, 7]
    

提交回复
热议问题