Dynamic Code Instrumentation with Hacked Interpreters
summary
Shows a working patched CPython that instruments every bytecode push by overriding the push macro, records when specific objects are touched, and emits JSON traces so one can infer where args and *kwargs actually flow. The hacked interpreter builds in ~30–45 minutes, runs examples with 60–100× slowdown, and can produce huge logs (about 4 GB for a 100‑line example*, ~3 MB for five lines). Enables taint tracking and call/arg provenance.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:05Need for interpreter hacking
- 3:35Star args and kwargs problem
- 9:54Why static analysis fails
- 17:17Dynamic analysis techniques
- 24:01Building hacked interpreter
- 30:26Practical applications and trade-offs
- 32:34Summary
related talks
24mHow two undergrads from the other side of the planet are speeding up...
01h 03mA tour of CPython's runtime
25mPython as a Hackable Language for Interactive Data Science
29mBuilding a JIT compiler for CPython
29mWhat they don't tell you about building a JIT compiler for CPython
32mProfiling at the speed of light
25mAdvanced Python
45mDon't Live Patch Your CPython Interpreter
