An ultralight drop-in module implementing the flyweight design pattern
- Step 1: install flywrench
pip install flywrench
- Step 2: import flywrench
from flywrench import Flywrench
- Step 3: subclass from flywrench
# instead of this
class SomeClass(object):
def __init__(self, args):
# more magic
# do this
class SomeClass(Flywrench):
def __init__(self, args):
# more magic
- Step 4: there is no Step 4
ENJOY!
- Move
- Perhaps garbage collection. Keep track of how many links there are to a given object in cache, and when the number of links hits zero, delete it