Skip to content

Instantly share code, notes, and snippets.

View torond's full-sized avatar

David Reinartz torond

View GitHub Profile
import json, os
from functools import lru_cache
def persistent_cache(func):
"""
Simple persistent cache decorator.
Creates a "cache/" directory if it does not exist and writes the
caches of the given func to the file "cache/<func-name>.cache"
"""
file_path = os.path.join('cache', f'{func.__name__}.cache')