coding are debugged quickly • They are also often easily recoverable • Python has stuff like `eval` so… there should be a way for me to hot swap code nicely
a module object, so it must have been successfully imported before. This is useful if you have edited the module source file using an external editor and want to try out the new version without leaving the Python interpreter. The return value is the module object https://docs.python.org/3/library/importlib.html#importlib.reload
data” • Modules are basically fancy dictionaries • Reloading code just means building new objects from source • Reloading a module just updates a dictionary • No real notion of “updating class methods”
instance (roughly) • Check class for data descriptors (__get__ and __set__) • Check instance for attribute • Check class for non-data descriptor or attribute https://medium.com/stepping-through-the-cpython-interpreter/how-does-attribute- access-work-d19371898fee
at runtime and have it be immediately reflected • Don't want to write something for each module • Ideal flow involves watching all files and reloading automatically
reload modules • Supports most object types, experimental function support from mighty_patcher.watch import AutoReloader reloader = AutoReloader( path="/path/to/my/project/src/" )
pytest test_directory --reload-loop • Activates debugger on test failures • Sets up code reloader • Retry test after code reloading • No instrumentation required
CPython extension debugging • Add some tricks to work around common framework issues • (Django registry pattern) • (Holy Grail) Be able to edit the call stack to recover at _exactly_ the error call site
Models • https://eev.ee/blog/2017/11/28/object-models/ • "The language also goes to almost superhuman lengths to expose all of its moving parts. Even the prototypical behavior is an implementation of __getattribute__ somewhere, which you are free to completely replace in your own types. ”
= 3 ctypes.pythonapi.PyFrame_LocalsToFast( ctypes.py_object(upper_frame), ctypes.c_int(0) ) def f(): x = 2 g() print(f"The value of x is {x}!") f() # The value of x is 3!