def load_memo(filename):
    with open(filename) as f:
        self.memo.update(json.load(f))

def save_memo(filename):
    with open(filename, 'w') as f:
        json.dump(self.memo, f)

def __call__(self, *args):
    if not args in self.memo:
        self.memo[args] = self.func(*args)
return self.memo[args]
memoize to disk - python - persistent memoization