How to change Python (while it's running)
summary
Live development of a running Python process by swapping function code objects is practical and implemented as Jurigged which watches files (watchdog), compiles new code in isolation and hot‑patches by updating function __code__ pointers after locating references via gc and the audit hook from Python 3.8. It updates functions methods and closures most of the time and adds a dunder conform protocol for library-specific state patches. Limits include object layout changes, running frames only seeing changes on next call, line‑number and decorator/JIT incompatibilities.
AI-written summary · about
chapters (14)
- 0:00Start
- 0:55What is live coding?
- 1:57Existing platforms
- 3:35We want to update functions
- 6:01We want to add update methods
- 7:21We want to update closures
- 11:30How a function is executed
- 14:31Patching a function
- 14:50Plan
- 17:33Find the old code object (bis)
- 18:43Find all functions
- 19:33Profit?
- 20:33What happens ?
- 22:41conform_protocol
related talks
14mPYLIVE: On-the-Fly Code Change for Python-based Online Services
45mDon't Live Patch Your CPython Interpreter
28mInstant-feedback, instant-debugging Python coding
49mThe Evolution of Python: Progress or Dead End
38mDynamic Code Instrumentation with Hacked Interpreters
28mKnocking On A Process’s Door: Introspecting Live Python Processes
29mBuilding a JIT compiler for CPython
41mAdvanced Python Debugging Techniques Using GDB
