Code reloading: challanges, approaches & libraries
summary
Python can update running code but semantics bite: def and class create new objects, default-arg captures and from-import copies keep old references, and renames linger in the interpreter. Two practical approaches appear: patch original objects (copy class dicts, swap function code objects) or update all pointers using GC referrers. Tools mentioned include importlib.reload, IPython autoreload and jurigged. A working case is an extended window manager that reloads its own code to avoid restarts; verbose logging proves essential to see what actually changes.
AI-written summary · about
chapters (16)
- 0:00Introduction to code reloading
- 1:35Historical demo in Smalltalk
- 4:12Language support and ideology
- 6:45Basic Python reloading concepts
- 9:31Binding and function references
- 10:57Singleton initialization pattern
- 12:48Risks of renaming variables
- 13:11Class redefinition challenges
- 14:37Python's built-in reload function
- 17:10Pointer update approaches
- 17:31Handling multiple file dependencies
- 19:41Updating object pointers
- 21:27Reloading libraries overview
- 22:29Importance of verbose logging
- 23:41Choosing the right library
- 24:04Alternatives to code reloading
