Skip to content
Opensource internals
  • Posts

Python

CPython's Cell Implementation in C: The One-Pointer Box Behind nonlocal

Oct 20, 2026 10 min read Jay Hubbert

A cell is a box with a single pointer in it, and closures work because two frames share the same box — not the same value — which is why late-binding captures the variable.

PythonCpythonInternalsCell

Read more →

CPython's code Implementation in C: Where the Bytecode Actually Lives

Oct 20, 2026 9 min read Jay Hubbert

A code object is pure, shareable syntax: bytecode plus constants, names, a unified localsplus layout, and two compact byte tables — the linetable and the exception table.

PythonCpythonInternalsCode

Read more →

CPython's complex Implementation in C: Two Doubles and a Freelist

Oct 20, 2026 8 min read Jay Hubbert

A complex number is 32 bytes: an object header plus two doubles. Arithmetic comes in a fast mixed-mode macro, and hashing guarantees hash(x+0j) == hash(x).

PythonCpythonInternalsComplex

Read more →

CPython's coroutine Implementation in C: The Generator That Awaits

Oct 20, 2026 6 min read Jay Hubbert

A coroutine is a generator with a different flag: CO_COROUTINE picks the type, RETURN_GENERATOR hands back the frame, and am_await wraps it so you can drive it like an iterator.

PythonCpythonInternalsCoroutine

Read more →

CPython's Descriptor Implementation in C: property, classmethod, staticmethod

Oct 20, 2026 8 min read Jay Hubbert

A descriptor is a type with tp_descr_get (and maybe tp_descr_set). Having a setter is what makes it a data descriptor — and that single bit decides who wins an attribute lookup.

PythonCpythonInternalsDescriptorProperty

Read more →

← Newer Page 2 of 11 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·