Explore specialized container datatypes like namedtuple, defaultdict, Counter, and deque.
Source Code
from collections import namedtuple, defaultdict, Counter, deque
# namedtuple for tuples with named fields
Point = namedtuple('Point', ['x', 'y'])
# defaultdict for dictionaries with default values
dd = defaultdict(int)
# Counter for counting hashable objects
cnt = Counter(['a', 'b', 'c', 'a'])
# deque for efficient appends and pops on either end
dq = deque([1, 2, 3])