Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于staticmethod的python percache_Python_Caching_Static Methods - Fatal编程技术网

基于staticmethod的python percache

基于staticmethod的python percache,python,caching,static-methods,Python,Caching,Static Methods,我试图在类staticmethod上使用这个包,但它似乎不起作用。对缓存静态方法有任何限制吗?是的,它可以正常工作示例 import percache cache = percache.Cache('pop.txt') class M(): @staticmethod @cache def f(a, b): print ('cool') return a + b print (M.f('pop', 'corn')) print

我试图在类
staticmethod
上使用这个包,但它似乎不起作用。对缓存静态方法有任何限制吗?

是的,它可以正常工作示例

import percache

cache = percache.Cache('pop.txt')


class M():

    @staticmethod
    @cache
    def f(a, b):
        print ('cool')
        return a + b


print (M.f('pop', 'corn'))
print (M.f('pop', 'corn'))

cache.close()