Writing A Python Interpreter for Fun & Profit
summary
A tiny Python VM compiles CPython bytecode and executes it with a simple C++ interpreter that actually works: a single recursive run_code loop with a big switch over opcodes, an object model implemented by C++ classes with intrusive ref counts, and C++↔Python bindings for calling back and forth. Implementation uses modern C++ and finishes in about five days as roughly 2000 lines of code, demonstrating multi-instance interpreters and straightforward extensibility.
AI-written summary · about
chapters (4)
- 0:00Start
- 2:03use the python compiler to compile it into bytecode
- 3:16add an wrapper
- 4:02unwrapping the arguments
related talks
59mHow to understand modern C++ features in practice? Let's create a compiler!
29mC++ ♥ Python: from modules to hybrid applications
29mGenerating Python bindings to C++ libraries
29mThe Art of Extending Python with other languages
33mBuilding with Multiple Languages: A Python-First Approach
01h 03mto pass and return, the story of functions, values and compilers
01h 04mExtending MicroPython: Using C for good!
28mTshepang Lekhonkhobe: Behind The Scenes Of Producing An Executable
