Commit

443ba2d

⚡How to swap a function's body at runtime in Python? A function is a thin wrapper: code object + globals + defaults + closure. The code object is just compiled bytecode and can be shared or replaced. This is how some hot-reload and mocking tools work.
python
def g(): return "g"
def h(): return "h"

h.__code__ = g.__code__
print(h())  # g

commit 443ba2d