CPython's LazyImport Implementation in C
Lazy imports work by parking a proxy object in the namespace and atomically replacing it with the real module the first time the name is touched.
Lazy imports work by parking a proxy object in the namespace and atomically replacing it with the real module the first time the name is touched.
CPython’s list is a contiguous array of pointers with a separate size and capacity, growing by about an eighth each time so appends stay O(1) amortized.
CPython splits memoryview into a shared managed-buffer snapshot and a per-view copy of shape/strides, so slicing adjusts pointers instead of copying data.
Every Python module is, at the C level, an instance of PyModule_Type. Unlike bool or int, a module is a mutable object whose “attributes” are just the entries of its dictionary. …
None is Python’s “no value” sentinel. There is exactly one instance of NoneType, it is immortal, it has no methods, and comparing it is just pointer equality. In CPython all of …