Code hot-swapping for Python 2.7 classes and functions.
GOAL: Feel a little bit like Bret Victor.
NON-GOAL: Provide a general solution for hot-swapping everything in all edge-case scenarios.
Decorate classes and functions that you would like to hot-swap with
from hottie import hot @hot class Rocket(object): '...'
Check out the demo.
pip install hottie
How it works
@hot functions are proxies to real functions and
@hot instances are observers that get their
.__class__ changed when their class is updated. This slightly decreases performance. If you want to take advantage of hot-swapping only in development, use
@hot like this:
import hottie if DEVELOPMENT: hot = hottie.hot else: hot = hottie.identity