Code reloading: challanges, approaches & libraries
Code reloading is fun! Python's semantics for def, class complicate it. There are multiple approaches and multiple libraries; I don't think any is one-size-fits-all. This talk will teach you how they work to make informed choice for your code.
Edit->reload cycle on running software may be more fun & productive than exiting and losing state. Python's semantics for class and defcreating a new object are not as friendly to reloading as Smalltalk/Lisp/Ruby which patch in-place. Reloading is still very possible, with multiple approaches and libraries but I believe you better understand the issues and implementation tradeoffs. - What importlib.reload() does and does not. - Copied references: from ... import ..., instances, callbacks & closures, etc. - => Recording what-imported-what dependency graph. - => Patching classes/functions in-place vs. Updating references? Limitations. - A secret weapon: gc.get_referrers() - What IPython's %autoreload, jurigged, limeade do? - Renames/deletions. Problem of intent. => jurigged AST diffing?! - Top-level code, singletons, derived values. => Hard. Idempotent try: except NameError: style.