The Python object model, PyObject and PyVarObject layout, reference counting, the garbage collector, memory allocators, and built-in type implementations.
| Chapter | Title |
|---|---|
| 7 | The Python Object Model |
| 8 | PyObject and PyVarObject |
| 9 | Reference Counting |
| 10 | The Garbage Collector |
| 11 | Memory Allocators |
| 12 | Object Layout and Type Slots |
| 13 | Built-in Object Implementations |
| 14 | Strings, Bytes, and Unicode |
| 15 | Lists, Tuples, and Arrays |
| 16 | Dictionaries and Sets |
| 17 | Integers, Floats, and Complex Numbers |
7. The Python Object ModelHow every value in Python is a heap-allocated object, and the role of type objects in defining behavior.
8. PyObject and PyVarObjectThe PyObject and PyVarObject C structs: ob_refcnt, ob_type, and the ob_size extension for variable-length objects.
9. Reference CountingPy_INCREF, Py_DECREF, and the deterministic lifetime rules that drive most memory reclamation in CPython.
10. The Garbage CollectorCycle detection algorithm, generational collection, gc thresholds, and the interaction with reference counting.
11. Memory AllocatorsThe pymalloc small-object allocator, arenas, pools, blocks, and when CPython falls back to system malloc.
12. Object Layout and Type SlotsPyTypeObject slot layout, tp_* function pointers, and how type slots encode object behavior for the interpreter.
13. Built-in Object ImplementationsC-level implementations of None, True, False, NotImplemented, and Ellipsis as statically allocated objects.
14. Strings, Bytes, and UnicodePyUnicodeObject internal encodings, the interning table, bytes vs. bytearray, and the codec infrastructure.
15. Lists, Tuples, and ArraysPyListObject dynamic resizing strategy, PyTupleObject immutability, and the array module's typed buffer.
16. Dictionaries and SetsCompact dict implementation, hash table probing, split-key sharing, and PySetObject collision resolution.
17. Integers, Floats, and Complex NumbersPyLongObject digit array for arbitrary precision, PyFloatObject IEEE 754 storage, and complex number layout.