CPython's Frame Implementation in C: Two Structs, One Activation Record
A CPython frame is really two structs: the compact _PyInterpreterFrame the VM runs on, and the heap PyFrameObject Python code only ever sees — created lazily, and copied if it …
A CPython frame is really two structs: the compact _PyInterpreterFrame the VM runs on, and the heap PyFrameObject Python code only ever sees — created lazily, and copied if it …
A Python function is a PyFunctionObject — a shared code object bolted to a globals dict, a tuple of defaults, and a tuple of closure cells — and every call goes through vectorcall.
Generators, coroutines, and async generators share one struct: an _PyInterpreterFrame embedded directly in the object, so a paused function is a single heap allocation.
int is a PyObject with a tag word packing sign and digit count plus a little-endian array of 30-bit digits — and every value in -5..1024 is an immortal singleton.
A for loop compiles to PyObject_GetIter plus repeated tp_iternext calls — two C function pointers, no Python-level dispatch for built-in types.