def memoize(fun):
    @wraps(fun)
    def wrapper(*args, **kwargs):
        key = (args, frozenset(sorted(kwargs.items())))
        try:
            return cache[key]
        except KeyError:
            ret = cache[key] = fun(*args, **kwargs)
        return ret
    cache = {}
    return wrapper
A simple memoize decorator for functions supporting positional args.
dataset/ETHPy150Open graphql-python/graphene/graphene/utils/caching.py/memoize