def memoize_faked(obj):
 cache = obj.cache = {}
 def memoizer(*args, **kwargs):
  key = (obj, args, frozenset(kwargs.items()))
  try:
   result = cache[key]
  except TypeError:
   return obj(*args, **kwargs)
  except KeyError:
   result = obj(*args, **kwargs)
   if (result is not None):
    cache[key] = obj(*args, **kwargs)
   return result
  else:
   return result
 return memoizer

def memoize_faked ( obj ) : cache = obj . cache = { } def memoizer ( * args , ** kwargs ) : key = ( obj , args , frozenset ( kwargs . items ( ) ) ) try : result = cache [ key ] except TypeError : return obj ( * args , ** kwargs ) except KeyError : result = obj ( * args , ** kwargs ) if ( result is not None ) : cache [ key ] = obj ( * args , ** kwargs ) return result else : return result return memoizer
a typical memoize function that ignores issues with non hashable results .