finitedepth.cache#

Caching helper.

Module Contents#

Functions#

attrcache(attrname)

Decorate a nullary method to cache the result with attribute.

finitedepth.cache.attrcache(attrname)[source]#

Decorate a nullary method to cache the result with attribute.

Method must not have any argument.

Examples

>>> from finitedepth.cache import attrcache
>>> class Foo:
...     @attrcache("_bar")
...     def bar(self):
...         print("spam")
...         return 1
>>> f = Foo()
>>> f.bar()
spam
1
>>> f.bar()
1
Parameters:

attrname (str) –