我在一个类中有一些属性方法,我想在某个时候清除此属性的缓存。
范例:
class Test():
def __init__(self):
pass
@property
@functools.lru_cache()
def prop(self):
# Compute some stuffs and return complex number
Run Code Online (Sandbox Code Playgroud)
如果我做self.prop.clear_cache(),在这里我得到以下错误信息:
AttributeError: 'numpy.complex128' object has no attribute 'cache_clear'
Run Code Online (Sandbox Code Playgroud)
clear_cache()适用于函数,但不适用于属性方法。有什么办法吗?