Tokenization, parsing, the AST, symbol tables, compiler passes, code objects, constants and locals, bytecode generation, and bytecode optimization.
| Chapter | Title |
|---|---|
| 18 | Tokenization |
| 19 | Parsing |
| 20 | The AST |
| 21 | Symbol Tables |
| 22 | Compiler Passes |
| 23 | Code Objects |
| 24 | Constants, Names, and Locals |
| 25 | Bytecode Generation |
| 26 | Bytecode Optimization |
18. TokenizationTokenize module internals, the C tokenizer in Parser/tokenize.c, and how indentation becomes INDENT/DEDENT tokens.
19. ParsingCPython's PEG parser, Grammar/python.gram, the generated Parser/parser.c, and parse tree construction.
20. The ASTAST node types defined in Parser/Python.asdl, the ast module, and how AST nodes map to source locations.
21. Symbol TablesScope analysis in Python/symtable.c: local, global, free, and cell variable classification before compilation.
22. Compiler PassesMulti-pass lowering from AST to CFG to linear bytecode, and the role of each compiler pass in Python/compile.c.
23. Code ObjectsPyCodeObject fields: co_code, co_consts, co_names, co_varnames, co_filename, and how they are used at runtime.
24. Constants, Names, and LocalsHow compile-time constants are folded, names interned, and local variable slots assigned in the code object.
25. Bytecode GenerationInstruction emission, jump fixup, and the assembler in Python/compile.c that produces the final bytecode array.
26. Bytecode OptimizationPeephole optimizer passes: constant folding, dead code elimination, and superinstruction formation in Python/flowgraph.c.