When Python general purpose built-in containers (tuple, list, set, and dict) aren't enough, we can find specialized container datatypes in the collections module. They are:
Data type | Description |
namedtuple() |
Factory function for creating tuple subclasses with named fields |
deque |
List-like container with fast appends and pops on either end |
ChainMap |
Dictionary-like class for creating a single view of multiple mappings |
Counter |
Dictionary subclass for counting hashable objects |
OrderedDict |
Dictionary subclass that remembers the order entries were added |
defaultdict |
Dictionary subclass that calls a factory function to supply missing values |
UserDict |
Wrapper around dictionary objects for easier dictionary subclassing |
UserList |
Wrapper around list objects for easier list subclassing |
UserString |
Wrapper around... |