Skip to content
Opensource internals
  • Posts

Str

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 →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·