skip to content
developertype

snippets

filter:96 snippets
py-gen-memoize·python·general
def memoize(fn):
    cache = {}
    def wrapper(*args):
        if args not in cache:
            cache[args] = fn(*args)
        return cache[args]
    return wrapper