: kids.cache
, kids.cache, , dict , .
>>> from kids.cache import cache
>>> @cache
... def meth(a, b):
... print("Taking some time", a, b)
... return a + b
:
>>> meth(1, 2)
Taking some time 1 2
3
>>> meth(1, 2)
3
:
>>> meth(1, 3)
Taking some time 1 2
4
:
>>> meth.cache_info()
CacheInfo(type='dict', hits=1, misses=2, maxsize=None, currsize=2)
kids.cache, , . , . , .
, , ( , dict), . , cachetools.
Perhaps you can also use out of the box kids.cache, which has extensive documents . It has no dependency, only one file running on python2 and python3 is easy to use, allowing complex caching if necessary.
source
share