def memoizemethod_noargs(method):
 cache = weakref.WeakKeyDictionary()
 @wraps(method)
 def new_method(self, *args, **kwargs):
  if (self not in cache):
   cache[self] = method(self, *args, **kwargs)
  return cache[self]
 return new_method

def memoizemethod_noargs ( method ) : cache = weakref . WeakKeyDictionary ( ) @ wraps ( method ) def new_method ( self , * args , ** kwargs ) : if ( self not in cache ) : cache [ self ] = method ( self , * args , ** kwargs ) return cache [ self ] return new_method
decorator to cache the result of a method using a weak reference to its object .