ian.g.kelly at gmail.com
Thu Nov 1 22:52:17 CET 2012
On Thu, Nov 1, 2012 at 3:38 PM, Andrea Crotti <andrea.crotti.0 at gmail.com> wrote:
> What I would like to write is
> def var_lazy(self):
> return long_computation()
> and this should imply that the long_computation is called only once..
If you're using Python 3.2+, then functools.lru_cache probably
suffices for your needs.
If you really need to shorten that to a single declaration:
More information about the Python-list