Introduction
This module implements specialized container datatypes providing alternatives to Pythonโs general purpose built-in containers, dict, list, set, and tuple.
What types does it offer?
Following are the most commonly used special container types of collections module,
Name | Purpose |
---|---|
Counter | dict subclass for counting hashable objects |
OrderedDict | dict subclass that remembers the order entries were added |
defaultdict | dict subclass that calls a factory function to supply missing values |
deque | list-like container with fast appends and pops on either end |
namedtuple | factory function for creating tuple subclasses with named fields |
And...
We can also implement a custom container type like OrderedCounter
using the container types provided by collections module.
The next series of posts will dive deep into the above mentioned container types provided by collections module.
Stay Tuned !
Top comments (0)