CPython’s internals# Exploring the internals CPython source code layout Additional references Guide to the parser Abstract How PEG parsers work Key ideas Consequences of the ordered choice operator Syntax Grammar expressions # comment e1 e2 e1 | e2 ( e ) [ e ] or e? e* e+ s.e+ &e !e ~ Left recursion Variables in the grammar Grammar actions Pegen How to regenerate the parser How to regenerate the meta-parser Grammatical elements and rules Tokenization Memoization Automatic variables Hard and soft keywords Error handling How syntax errors are reported Generating AST objects Testing Debugging generated parsers Making experiments Verbose mode References Compiler design Abstract Parsing Abstract syntax trees (AST) Memory management Source code to AST Control flow graphs AST to CFG to bytecode Introducing new bytecode Code objects Important files Known compiler-related experiments References The bytecode interpreter (3.11) Preface Other sources Introduction Code objects Instruction decoding Jumps Inline cache entries The evaluation stack Error handling Exception table format The locations table Exception chaining Python-to-Python calls The call stack All sorts of variables Other topics Garbage collector design Abstract Memory layout and object structure Identifying reference cycles Why moving unreachable objects is better Destroying unreachable objects Optimization: generations Collecting the oldest generation Optimization: reusing fields to save memory Optimization: delay tracking containers