0. 标题
Python专家编程系列: 3. 善用装饰器使代码提高一个层次(Powerful Python Decorator)
作者: [email protected]
blog: https://blog.csdn.net/quant_galaxy
欢迎交流
1. 常用的装饰器
1.1 cache
请注意,它仅适用于 Python >= 3.9。
这样就可以缓存以前的值并重复使用,而不是重新计算。
from functools import cache
@cache
def factorial(n):