def memoize_method(method):
 def wrapper(self, *args, **kwargs):
  dct = self.__dict__.setdefault('_memoize_method_dct', {})
  key = (args, frozenset(kwargs.items()))
  try:
   return dct[key]
  except KeyError:
   result = method(self, *args, **kwargs)
   dct[key] = result
   return result
 return wrapper

def memoize_method ( method ) : def wrapper ( self , * args , ** kwargs ) : dct = self . __dict__ . setdefault ( '_memoize_method_dct' , { } ) key = ( args , frozenset ( kwargs . items ( ) ) ) try : return dct [ key ] except KeyError : result = method ( self , * args , ** kwargs ) dct [ key ] = result return result return wrapper
a normal memoize function .