初探缓存装饰器
平常学习过程发现了一个牛掰装饰器,在此记录下
1 from functools import lru_cache 2 3 4 @lru_cache() 5 def count(a, b): 6 print("对{},{}求和".format(a, b)) 7 return sum([a, b]) 8 9 10 if __name__ == '__main__': 11 print(count(4, 5)) 12 print(count(4, 5))
output;
对4,5求和
9
9