Skip to content
Opensource internals
  • Posts

Posts

All posts published on this site.

Everything published here, newest first.

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 →

CPython's dict Implementation in C: Combined Tables, Split Keys, and the Probe Sequence

Oct 20, 2026 9 min read Jay Hubbert

CPython’s dict is a hash table with a twist: compact and insertion-ordered since 3.6, and able to share a single keys object across thousands of instances.

PythonCpythonInternalsDict

Read more →

CPython's Ellipsis Implementation in C: One Immortal Singleton

Oct 20, 2026 7 min read Jay Hubbert

There’s exactly one Ellipsis, and it’s immortal: a static struct initialized with a refcount of 3«30 so that no increment or decrement can ever bring it to zero.

PythonCpythonInternalsEllipsis

Read more →

CPython's enumerate Implementation in C: Lazy Iterators with a Recycled Tuple

Oct 20, 2026 8 min read Jay Hubbert

enumerate, zip and reversed don’t build lists: they’re lazy C iterators that reuse one result tuple and mutate it in place, so a for loop over them allocates almost nothing.

PythonCpythonInternalsEnumerateZipReversed

Read more →

← Newer Page 16 of 53 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·