Languages
Reading programming languages from their own source — the standard-library files and runtime internals that define how the language actually behaves, walked line by line.
Sub-topics
- Python — How Python works where it is written in Python: the standard library and CPython internals, read closely — concurrency primitives, data structures, and the idioms the language ships with.
Explainers
- The GIL, Honestly — One mutex around the interpreter lets only one thread run Python bytecode at a time — and yet x += 1 can still lose an update. Watch the race survive the GIL op by op, then pick threading, multiprocessing, or asyncio from a computed wall-clock, and see what 3.13 free-threading really changes.
- CPython’s queue.py, Line by Line — The real bounded blocking queue from the standard library you already import. One mutex, three Conditions, and the not-empty / not-full invariants — walk the whole file top to bottom and watch the monitor block, wake, and drain.
- functools.lru_cache, Line by Line — The canonical interview prompt — build a thread-safe LRU cache with O(1) get and put — answered in production Python. Walk the real functools.py: the flattened key, the circular doubly linked list, the pointer surgery that moves a hit to the front, the reuse-the-oldest-node eviction trick, and the one RLock that keeps it all consistent.
- Python’s Dict, Under the Hood — A namespace, a set of keyword arguments, and an object’s attributes are all the same thing: a dict. Walk the CPython hash table that powers them — open addressing, the perturb probe sequence, the compact two-array layout that made insertion order a language guarantee, resizing, and SipHash — with the probe walked live over a real hash.
- Python Gotchas That Fail Interviews — Eight snippets that look obvious and aren’t — mutable default arguments, late-binding closures, is vs ==, chained comparisons, mutation during iteration, shallow copies, shared class attributes, and a finally that eats a return. Predict each output, then meet the one evaluation-model rule underneath. Every result run in real CPython, every claim traced to the docs.
- Iterators, Generators & the Dunder Protocols — Python has no interfaces — a syntax works on your object when the object supplies the right dunder. Desugar a for-loop into iter/next/StopIteration, watch a generator freeze mid-frame on yield, and tour the protocol family behind in, len, bool, with, and ==. Computed and animated.
- Errors, Edge Cases & Testing in the Room — Juniors code the happy path; seniors enumerate what breaks first. The edge-case checklist as a habit, raise-with-context and exception chaining, assert vs exceptions and the -O caveat, a five-minute inline self-test, and property thinking without a framework — worked on one binary search, every snippet run in real Python.
- Designing a Clean Python API Under Pressure — The low-level-design round grades your interface, not your diagram. Build one small key-value store live — but design only: derive the API from the call site first, state and enforce the invariants, shape the exception surface, add dunders where they earn their keep, and let the docstring be the spec. Every snippet runs in real CPython.
- Idiomatic Python — The same program, written twice — once with a C accent, once the way Python wants. Comprehensions, unpacking, the right dict idiom, dataclasses, context managers, EAFP, f-strings, pathlib, and truthiness — each as a before/after pair, with the honest case for when NOT to reach for the idiom. Every snippet run in real CPython.
- Writing Python Interviewers Trust — One real interview problem — parse a log file, report the top-N error codes per service — solved twice and walked side by side: the rushed 26-line function (single-letter names, a bare except, prints, mutates its input) versus the trustworthy version (small functions, guard clauses, honest exceptions, a pure core and a thin I/O edge). The refactor as six trust signals you can name and practise.