defaultdict gives a default for missing keys so you stop writing if k not in d: d[k] = []. Counter is a dict that counts hashable items and exposes .most_common(n). namedtuple is a tiny, immutable record. deque gives O(1) append/pop at both ends.
Counter(words).most_common(10) gives the most frequent words in a line.
defaultdict(list) groups: for k, v in pairs: d[k].append(v) - no KeyError.
deque for sliding window: d.append(x); if len(d) > K: d.popleft().
namedtuple(“RGB”, “r g b”)(255,0,0) reads better than dict.
Counter for frequencies
defaultdict for group-by
deque for sliding window
namedtuple for readable small records
Don’t reinvent counting, grouping, sliding windows, or named records. Use collections.