Skip to content
Opensource internals
  • Posts

Cpython

CPython's str Implementation in C (Unicode): One Byte per Character When You Can

Oct 20, 2026 10 min read Jay Hubbert

A CPython str picks the narrowest of 1, 2, or 4 bytes per code point at allocation time — so an all-ASCII string is one allocation with no UTF-8 cache at all.

PythonCpythonInternalsStrUnicode

Read more →

CPython's structseq Implementation in C (PyStructSequence): Tuples With Names

Oct 20, 2026 9 min read Jay Hubbert

A struct sequence is a tuple subclass whose hidden fields live past ob_size in the same allocation — so len() sees only the visible ones while attributes see everything.

PythonCpythonInternalsStructseq

Read more →

CPython's super() Implementation in C: Cooperative Multiple Inheritance

Oct 20, 2026 8 min read Jay Hubbert

super() is not special syntax — it’s a three-pointer C object, and the compiler even skips building one for super().attr via the LOAD_SUPER_ATTR bytecode.

PythonCpythonInternalsSuperMro

Read more →

CPython's Template String Implementation in C (t-strings): Interpolation as Data

Oct 20, 2026 11 min read Jay Hubbert

t-strings produce a Template object — literal strings plus Interpolation objects — not a formatted string, so the pieces stay inspectable and reusable.

PythonCpythonInternalsStringsTemplate

Read more →

CPython's tuple Implementation in C: Immutable, Inline, and Recycled

Oct 20, 2026 8 min read Jay Hubbert

A CPython tuple has no separate buffer — the item array is embedded in the object, so its memory footprint is exactly its length and nothing more.

PythonCpythonInternalsTuple

Read more →

← Newer Page 8 of 11 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·