[issue21145] Add the @cached_property decorator

Antoine Pitrou report at bugs.python.org
Mon May 19 00:36:55 CEST 2014


Antoine Pitrou added the comment:

Does this work for you?

>>> class X:
...   @property
...   @functools.lru_cache(None)
...   def get_x(self):
...     print("computing")
...     return 5
... 
>>> x = X()
>>> x.get_x
computing
5
>>> x.get_x
5

----------
nosy: +pitrou, serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21145>
_______________________________________


More information about the Python-bugs-list mailing list