(func)
return wrap
Decorator for memoizing a function.
Decorator for memoizing a function.
Decorator for memoizing a function .
def memoize(func):
    """Decorator for memoizing a function."""
    cache = {}
    @wraps(func)
    def wrap(*args):
        if args not in cache:
            cache[args] = func(*args)
        return cache[args]
    return wrap
def memoize ( func ) : cache = { } @ wraps ( func ) def wrap ( * args ) : if args not in cache : cache [ args ] = func ( * args ) return cache [ args ] return wrap