📜  字典缓存 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:12.880000             🧑  作者: Mango

代码示例1
def memoize(func):
    cache = dict()

    def memoized_func(*args):
        if args in cache:
            return cache[args]
        result = func(*args)
        cache[args] = result
        return result

    return memoized_func