Exploring Python Code Objects
summary
CPython 2.7 actually compiles source to bytecode (about 148 opcodes), and the demo shows using compile() and exec on a source string, then reading co_code, co_names, constants and stack size and disassembling with the dis module. The bytecode for max and temp/out is stepped through, the VM loop in ceval.c and binary_add C path are inspected, exec is flagged slow and unsafe, closures show cellvars and func_closure, and the examples all run as shown.
AI-written summary · about
chapters (10)
- 0:00Start
- 2:02CPYTHON
- 3:02BYTECODE?
- 4:38MAKE YOUR OWN
- 7:41MAKE IT GO
- 11:32UNDER THE HOOD
- 18:23CEVAL.C
- 21:54CLASSES ARE CODE, TOO
- 23:54CLOSURES
- 53:14ZOOMING OUT
related talks
50mExploring CPython's bytecode
32mBytecode and .pyc files
50mExploring CPython's bytecode
22mLow Level Python a Deep dive into the python sources
31mUnderstanding Python from the inside: C concepts to dive into CPython fearless
34mCPython internals and the VM
33mLinear Genetic Programming in Python Bytecode
33mSource code processing with Python
