Third party data structures
Key 3: Using third-party data structures.
Python has a good bunch of data structures in the core language/library. But sometimes, an application has very specific requirements. We can always use third-party data-structure packages. Most of such modules are Python wrapper over C, C++ implementations:
- The
blistmodule provides a drop-in replacement for list,sortedList, andsortedset. It is discussed in greater detail in later chapters. - The
bintreesmodule provides binary, AVL tree, and Red-Black trees. - The
banyanmodule provides Red-Black trees, splay tree, and sorted lists. - The
Sortedcontainersmodule providesSortedList,SortedDict, andSortedSet. So, one can get almost every data structure for Python easily. More stress should be given on why one data structure is better than another for a use case.
Arrays/List
For numeric calculations involving math, NumPy arrays should be considered. They are fast, memory-efficient, and provide many vector and matrix operations...