Python

Python for interviews and production: cost tables, animated CPython internals (list growth, hashing, aliasing, scope, generators), workflows from import to PyPI and production, and 66 runnable cards with 12 real-world problems.

Overview

What this page is

A reference to scan in the middle of a problem or an incident, not a tutorial. The tables answer which container, what an operation costs and which call does the job. The animations show the mechanisms people get wrong, the workflow diagrams show Python in production, and 66 runnable cards hold the code. Every card checks itself with assert lines on Python 3.11, the version the Run button uses.

  • Core language — 01 to 31 — syntax, strings, lists, dicts, functions, classes, errors, generators
  • Standard library — 32 to 40 — Counter, defaultdict, deque, heapq, bisect, itertools, functools
  • Templates — 41 to 44 — two pointers, sliding window, graphs, backtracking, bits
  • Checks — 45 to 51 — infinity and NaN, gotchas, version fallbacks, regex, dates, testing, idioms
  • Real-world problems — 52 to 63 — log parsing, rate limiting, caching, top-k streams, calendars, retries, batching, config, validation, parsing, concurrency, percentiles
  • Production — 64 to 66 — memory, profiling, typing
  • Costs — list over-allocation, pop(0) against deque.popleft, set hashing against a list scan
  • Names and objects — [[0] * m] * n, alias against shallow and deep copy, the mutable default
  • Scope — LEGB lookup, late-binding closures
  • Laziness — the order in which a generator pipeline pulls values
  • Workflows — import, packaging and release, a FastAPI service, a batch data pipeline

> [!NOTE] Numbers such as byte sizes and capacities on this page are CPython 3.11 on a 64-bit machine. Other versions and PyPy can differ; the reasons do not.

Sign up free to read the full topic

More Quick References topics

Start free on Cariara · Coding problems · System design studio