Additionally to the built-in data types that you've worked with extensively by now, Python also comes pre-packaged with a many additional data structures in the standard library. That means that they are only one import statement away!
Data Structures in Python Collections
One of these libraries is called collections and it provides specialized container data types:
deque: list-like container with fast appends and pops on either endnamedtuple(): factory function for creating tuple subclasses with named fieldsChainMap: dict-like class for creating a single view of multiple mappingsCounter: dict subclass for counting hashable objectsOrderedDict: dict subclass that remembers the order entries that were addeddefaultdict: dict subclass that calls a factory function to supply missing valuesUserDict: wrapper around dictionary objects for easier dict subclassingUserList: wrapper around list objects for easier list subclassingUserString: wrapper around string objects for easier string subclassing
A specialized container is just what you need for a better implementation of a stack and a queue data structure, and you'll use one of these classes in the next lesson to do just that.
Can you figure out which of them might be a good candidate from reading the short descriptions taken from the Python documentation?
Summary: Types of Python Collections
- The collections module comes with several specialized container data types
- These specialized containers offer better implementations of a Stack and Queue
Specialized Container Data Types in Collections
dequenamedtuple()ChainMapCounterOrderedDictdefaultdictUserDictUserListUserString