SortedContainers is an Apache2 licensed containers library, written in pure-Python, and fast as C-extensions.