The evaluation loop, frames, stack-based execution, bytecode instructions, function and method calls, attribute lookup, exceptions, generators, coroutines, pattern matching, comprehensions, and closures.
| Chapter | Title |
|---|---|
| 27 | Evaluation Loop |
| 28 | Frames |
| 29 | Stack-Based Execution |
| 30 | Bytecode Instructions |
| 31 | Function Calls |
| 32 | Method Calls |
| 33 | Attribute Lookup |
| 34 | Exception Handling |
| 35 | Generators |
| 36 | Coroutines and Async |
| 37 | Pattern Matching |
| 38 | Comprehensions |
| 39 | Closures and Cells |
27. Evaluation LoopThe main evaluation loop in Python/ceval.c, opcode dispatch via computed gotos, and the eval breaker mechanism.
28. FramesPyFrameObject and _PyInterpreterFrame layout, frame creation, the frame stack, and frame introspection.
29. Stack-Based ExecutionThe value stack, operand push/pop discipline, and how the interpreter maintains stack depth invariants.
30. Bytecode InstructionsCatalogue of CPython opcodes: LOAD/STORE variants, binary ops, comparison, jumps, and call instructions.
31. Function CallsCALL opcode mechanics, positional and keyword argument handling, *args/**kwargs unpacking, and call overhead.
32. Method CallsLOAD_METHOD and CALL_METHOD optimization, bound method objects, and the method cache.
33. Attribute LookupLOAD_ATTR bytecode, __getattribute__ dispatch, the descriptor protocol, and type version tag caching.
34. Exception HandlingException tables, the try/except/finally bytecode pattern, exception chaining, and the unwinding protocol.
35. GeneratorsGenerator object internals, YIELD_VALUE and RESUME opcodes, and frame suspension and resumption mechanics.
36. Coroutines and Asyncasync def, await, SEND opcode, coroutine wakeup, and how asyncio integrates with CPython's coroutine machinery.
37. Pattern Matchingmatch/case compilation to MATCH_* opcodes, pattern semantics, and guard evaluation in the interpreter.
38. ComprehensionsHow list/dict/set comprehensions and generator expressions compile to nested code objects with implicit iteration.
39. Closures and CellsMAKE_CELL, LOAD_DEREF, STORE_DEREF opcodes and the PyCellObject that captures variables in enclosing scopes.