Python: From Source to Execution
summary
Starts from a tiny snippet and traces concrete steps: the tokenizer produces tokens, the parser builds an AST, the compiler emits a code object with co_consts/co_code and name tables, and the assembler resolves jumps from a control flow graph into bytecode so the VM can run it. Demonstrations use compile() and the disassembler module on 1+2 showing the stack VM, about 150 opcodes, optimizer effects, and how frames provide the runtime environment.
AI-written summary · about
chapters (9)
- 0:00Python internals intro
- 2:10Simple Python code
- 3:12Tokenizing source code
- 4:35Parsing tokens into an abstract syntax tree
- 9:07AST to bytecode
- 12:36Understanding bytecode
- 21:32Frame objects
- 23:39Core execution loop
- 25:48Summary
related talks
24mThe AST and Me
27mCPython's Compilation Pipeline
26mThe Long Hello World
50mExploring CPython's bytecode
27mPython is Weird
50mExploring CPython's bytecode
27mAn Executable Semantics for Faster Development of Optimizing Python Compilers
30mDemystifying Python’s Internals: Diving into CPython by implementing...
