Skip to content
Opensource internals
  • Posts

Posts

All posts published on this site.

Everything published here, newest first.

CPython's PyCapsule Implementation in C: A void* Wrapper for Extension Modules

Oct 20, 2026 9 min read Jay Hubbert

A PyCapsule is a typed, name-checked void* wrapper: the name stops you reading the wrong capsule, and the destructor gets one shot to clean up before the memory goes.

PythonCpythonInternalsCapsule

Read more →

CPython's range Implementation in C: Lazy Sequences That Never Materialize

Oct 20, 2026 7 min read Jay Hubbert

range holds four PyObject pointers and nothing else — the numbers are computed on demand, so range(10**18) costs the same as range(3).

PythonCpythonInternalsRange

Read more →

CPython's Sentinel Implementation in C: Unique Marker Objects for Defaults

Oct 20, 2026 8 min read Jay Hubbert

Each sentinel() call allocates a distinct, GC-tracked object that infers its module from the calling frame — which is exactly what makes it picklable.

PythonCpythonInternalsSentinel

Read more →

CPython's set and frozenset Implementation in C: One Hash Table, Two Flavors

Oct 20, 2026 9 min read Jay Hubbert

CPython’s set is an open-addressing hash table with three slot states — unused, dummy, active — and dummies are what keep deleted keys from breaking probe chains.

PythonCpythonInternalsSet

Read more →

CPython's SimpleNamespace Implementation in C

Oct 20, 2026 7 min read Jay Hubbert

SimpleNamespace is a PyObject_HEAD plus a single dict pointer — tp_dictoffset points right at it, so attribute access is just dict lookup.

PythonCpythonInternalsNamespace

Read more →

← Newer Page 21 of 53 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·