Finalization is where simple models fail
Design reliable cleanup around context managers, finalizers, cycles, resurrection, shutdown, async cancellation, and process exit.
Independent field notes / Vol. 01
Precise explanations of the machinery, patterns, and tradeoffs that make Python feel deceptively simple.
Read the cover storyThe index
49 notes, edited for signal.
Design reliable cleanup around context managers, finalizers, cycles, resurrection, shutdown, async cancellation, and process exit.
Build a small import hook while learning how finders, module specs, loaders, caches, packages, and failure cleanup divide responsibility.
Model pytest setup as a scoped dependency graph with explicit ownership, caching, and teardown edges.
Trace Python name resolution through live frames, fast locals, module globals, builtins, and the namespace rules around exec.
Separate Python call semantics from CPython vectorcall, then design APIs that avoid needless argument and boundary overhead.
Build a precise model of CPython object lifetime, cycles, finalizers, weak references, and the diagnostics that can accidentally keep objects alive.
Trace a class statement through namespace preparation, body execution, metaclass construction, descriptors, and subclass hooks.
Test import-time behavior without confusing module caching, finder caches, reload, and process isolation.
Editorial policy
No listicles. No folklore. No just trust me abstractions.
Every note should leave you with a better model of the system, not just another snippet to paste.