Skip to content
Opensource internals
  • Posts

Python

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 →

CPython's Exception Implementation in C: Objects All the Way Down

Oct 20, 2026 7 min read Jay Hubbert

Exceptions are ordinary GC-tracked objects with a shared PyException_HEAD prefix, plus a linked list of traceback frames and two chaining slots for context and cause.

PythonCpythonInternalsExceptions

Read more →

CPython's float Implementation in C: A double and a Freelist

Oct 20, 2026 7 min read Jay Hubbert

A float is 24 bytes holding one IEEE-754 double. Arithmetic converts both sides to double and boxes the result, and repr always uses 17 significant digits with a trailing .0.

PythonCpythonInternalsFloat

Read more →

← Newer Page 3 of 11 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·