5 Years of Bad Ideas
summary
Rundown of concrete hacks: uses sys._getframe, metaclasses, exec/compile and the ast module to rewrite code, builds a GitHub importer that actually imports modules straight from GitHub (very slow but functional), implements a multiversion import system that renames modules and proxies by caller frame (surprisingly works), and patches tracebacks with ctypes traceback patching to remap template line numbers for debugging. Most techniques work but are brittle, slow, and break across Python versions or production environments.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 0:36What is spiking
- 1:37What is magic
- 3:23Common magic
- 5:41Classes
- 6:14Xik
- 7:35AST
- 8:27Style Markers
- 10:58Monkey patching
- 11:13Underbuilding
- 12:48System Modules
- 14:55Curvy Loading
- 16:04Multi Versioning
- 17:54Interpreter Warfare
- 18:12Local Variables
- 19:04Line Numbers
- 21:18Garbage Collection
- 22:26Implicit Self
- 24:08Return Values Ideas
- 39:18Global Dictionary
related talks
31mDon't Do This
24m"A Confession of My Python Sins"
57mTechniques learned from five years finding the way for Rust in Python
36mHacking the Python AST
43mPython and Johnny Cash
28mHere be dragons: some elegant and ugly hacks in CPython
25mPython as a Hackable Language for Interactive Data Science
21mHacking the Python Import System
