def memoizedproperty(func):
 inner_attname = ('__%s' % func.__name__)
 def new_fget(self):
  if (not hasattr(self, '_cache_')):
   self._cache_ = dict()
  cache = self._cache_
  if (inner_attname not in cache):
   cache[inner_attname] = func(self)
  return cache[inner_attname]
 return property(new_fget)

def memoizedproperty ( func ) : inner_attname = ( '__%s' % func . __name__ ) def new_fget ( self ) : if ( not hasattr ( self , '_cache_' ) ) : self . _cache_ = dict ( ) cache = self . _cache_ if ( inner_attname not in cache ) : cache [ inner_attname ] = func ( self ) return cache [ inner_attname ] return property ( new_fget )
decorator to cause a method to cache its results in self for each combination of inputs and return the cached result on subsequent calls .