10.11.21 01:47, Bob Fang пише:
- 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.
From my C++ and Java experience, hashtable-based containers are much more useful than tree-based containers. They are more compact and fast. In most cases the only reason of using sorted container is supporting deterministic iteration order, but often it is enough to sort data only for output. It is easy to do with the sorted() builtin in Python.
We need some dict implementatin in Python, it is essential part of the language used to implement modules, classes and objects. And hashtable-based implementation is good for this. There is no such need of tree-based implementation. It is not needed in Python core, and is not needed for most users. So it is good to keep it in third-party libraries. Maintaining it in the stdlib has a cost and the benefit/cost value would be low.