sys.modules and the truth about import caching
Trace module identity, partial initialization, reloads, and cache invalidation through Python's real import protocol.
Independent field notes / Vol. 01
Precise explanations of the machinery, patterns, and tradeoffs that make Python feel deceptively simple.
Read the cover storyThe index
29 notes, edited for signal.
Trace module identity, partial initialization, reloads, and cache invalidation through Python's real import protocol.
Immutability, hashing, packing bytecode, shallow memory, and choosing records that communicate their shape.
Use weak references, weak containers, and finalizers without confusing reachability, equality, callbacks, or cache policy.
Hashes, collisions, compact entries, and the implementation choices behind Python's most important container.
What CPython locks, what it does not guarantee, and how free-threaded Python changes the decision.
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.