Skip to content
Opensource internals
  • Posts

Posts

All posts published on this site.

Everything published here, newest first.

CPython's Iterator Implementation in C

Oct 20, 2026 8 min read Jay Hubbert

A for loop compiles to PyObject_GetIter plus repeated tp_iternext calls — two C function pointers, no Python-level dispatch for built-in types.

PythonCpythonInternalsIterator

Read more →

CPython's LazyImport Implementation in C

Oct 20, 2026 10 min read Jay Hubbert

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.

PythonCpythonInternalsLazy importImport

Read more →

CPython's list Implementation in C

Oct 20, 2026 7 min read Jay Hubbert

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.

PythonCpythonInternalsList

Read more →

CPython's memoryview Implementation in C

Oct 20, 2026 9 min read Jay Hubbert

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.

PythonCpythonInternalsMemoryviewBuffer protocol

Read more →

CPython's Module Implementation in C

Oct 20, 2026 9 min read Jay Hubbert

A Python module is a PyModuleObject with a dict as its namespace, plus optional per-module C state — and its tp_getattro is where lazy imports get resolved.

PythonCpythonInternalsModule

Read more →

← Newer Page 19 of 53 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·