Sorted Containers is a pure-Python library providing sorted list, sorted dictionary, and sorted set data structures. It addresses the need for performant sorted collections beyond the standard library, offering an alternative to C-extension based implementations. The library prioritizes performance and a pragmatic design, utilizing a fragmenting approach for fast insertion.
Notable for its pure-Python implementation with performance comparable to C extensions, comprehensive benchmarking, 100% test coverage, and a compatible API. It offers a pragmatic design with features like a SortedSet being a SortedList with a SortedList index, providing a feature-rich and efficient alternative to standard Python collections.
- Pure-Python: Implementation is entirely in Python, eliminating dependency on C compilers or extensions.
- Performance: Designed for speed, often outperforming C implementations, with extensive benchmarks and stress testing.
- API Compatibility: Provides a compatible API to older modules like
blistandbintreesfor ease of transition. - Comprehensive Testing: Includes 100% test coverage with unit tests and hours of stress testing for reliability.
- Feature-Rich: Includes features like accessing the largest k keys in a SortedDict, and generally offers more functionality than standard data structures.
The project is mature with a long development history, comprehensive documentation, extensive testing, and active community contributions. It has been tested across multiple Python versions and operating systems, indicating a stable and reliable foundation.
Sorted Containers benefits developers by providing high-performance, easy-to-use sorted collection types without the complexity of C extensions. It is valuable for applications requiring efficient sorted data management, such as algorithmic trading, binary analysis, and asynchronous I/O, offering a robust and proven alternative to standard Python collections.
