cutcutcodec.core.opti.cache.basic.method_cache

cutcutcodec.core.opti.cache.basic.method_cache(meth: callable) callable[source]

Cache a class method.

Examples

>>> from cutcutcodec.core.opti.cache.basic import method_cache
>>> i = 0
>>> class Foo:
...     @method_cache
...     def f(self, x):
...         global i
...         i += x
...         return i
...
>>> foo = Foo()
>>> foo.f(1)
1
>>> foo.f(1)
1
>>>