Don't Live Patch Your CPython Interpreter
summary
A pip‑installable C extension called ratch live‑patches CPython by assembly‑trampolining the py_eval_frame_x loop and injecting callbacks (get_rat/set_rat) so every VM stack push/pop can trigger a hook. Demos include nested Python 3/2/1 interpreters in one process and read‑watches that can lazy‑evaluate or double integers. The patch is version‑specific (only Python 3.5.0 / 3.5.4 / 3.4.3 provided), requires ~50–60 LOC kernel changes, and fails on Windows and many C modules (numpy).
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:24Why avoid this code
- 2:06Exploring Python examples
- 4:57Temptation of live patching
- 7:00Introducing read watches
- 11:14How read watches work
- 15:08Never live patch CPython
- 17:54Technical judgment in coding
- 28:09Guiding technical judgment
- 37:59When live patching is acceptable
- 39:22PEP 523 and CPython patching
- 40:26Audience questions on technical sophistication
related talks
29mBuilding a JIT compiler for CPython
30mHow to change Python (while it's running)
38mDynamic Code Instrumentation with Hacked Interpreters
32mWriting Extension Modules To Be Interruptible
20m`from __past__ import print_statement`: a Dadaist Rejection of Python 2 vs 3
31mHear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.
28mPipe-ifying Python: The how and why of interpreter hacking
29mWhat they don't tell you about building a JIT compiler for CPython
