Maybe not the best, but
from functools import lru_cache class Example: @property def a_getter(self): return self._a_getter() @lru_cache(maxsize=None) def _a_getter(self): print('Doing an expensive operation!') expensive_result = 5 return expensive_result test = Example() for i in range(0, 1000): a_variable = test.a_getter print(test._a_getter.cache_info())would be interesting to see other suggestions
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs