atexit.register(lambda : json.dump(cache, open(file_name, 'w')))

def decorator(func):

    def new_func(param):
        if param not in cache:
            cache[param] = func(param)
return cache[param]
return new_func
return decorator
memoize to disk - python - persistent memoization