def cached(f):

    cache = f.cache = {}

    @functools.wraps(f)
    def decorator(*args, **kwargs):
        key = str(args) + str(kwargs)
        if key not in cache:
            cache[key] = f(*args, **kwargs)
        return cache[key]
    return decorator
Cache decorator for functions taking one or more arguments.
dataset/ETHPy150Open viniciuschiele/flask-apidoc/flask_apidoc/utils.py/cached