Skip to content
Opensource internals
  • Posts

Python

CPython's async generator Implementation in C: Everything Is an Awaitable

Oct 20, 2026 6 min read Jay Hubbert

An async generator never runs when you call it: anext(), asend(), athrow() and aclose() all return awaitables that the event loop drives.

PythonCpythonInternalsAsyncGenerator

Read more →

CPython's bool Implementation in C: Two Immortal Integers

Oct 20, 2026 7 min read Jay Hubbert

Python has exactly two bool objects ever: True and False are immortal static structs that happen to be ints 1 and 0, and bool(x) just picks one.

PythonCpythonInternalsBool

Read more →

CPython's Bound Method Implementation in C (types.MethodType)

Oct 20, 2026 8 min read Jay Hubbert

types.MethodType is a GC-tracked pair of im_func and im_self — binding happens in the descriptor, and calling prepends self to the argument vector.

PythonCpythonInternalsMethod

Read more →

CPython's bytearray Implementation in C: A bytes Object You Can Mutate

Oct 20, 2026 8 min read Jay Hubbert

A bytearray doesn’t own its buffer: it points into a PyBytesObject, so it inherits bytes’ allocator and NUL guarantee, and it refuses to resize while C code holds a view.

PythonCpythonInternalsBytearray

Read more →

CPython's bytes Implementation in C: One Trailing NUL and a Cached Hash

Oct 20, 2026 7 min read Jay Hubbert

A bytes object is a length plus a char array ending in NUL, with its hash cached lazily and 257 immortal singletons covering the empty and single-byte cases.

PythonCpythonInternalsBytes

Read more →

← Newer Page 1 of 11 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·