Back to search

collections and functools helpers: `defaultdict`, `Counter`, `deque`, `namedtuple`, `partial`, `reduce`, and `lru_cache`

These helpers reduce boilerplate for grouping, counting, queue behavior, lightweight record types, partial application, reduction, and memoization.

Python Medium Theory

collections and functools helpers: `defaultdict`, `Counter`, `deque`, `namedtuple`, `partial`, `reduce`, and `lru_cache`

These helpers reduce boilerplate for grouping, counting, queue behavior, lightweight record types, partial application, reduction, and memoization.

  • `Counter` counts fast
  • `deque` is strong for queues
  • `lru_cache` adds memoization with little code

collections and functools helpers: `defaultdict`, `Counter`, `deque`, `namedtuple`, `partial`, `reduce`, and `lru_cache`