def memoized(maxsize=1024):
 cache = SimpleCache(maxsize=maxsize)
 def decorator(obj):
  @wraps(obj)
  def new_callable(*a, **kw):
   def create_new():
    return obj(*a, **kw)
   key = (a, tuple(kw.items()))
   return cache.get(key, create_new)
  return new_callable
 return decorator

def memoized ( maxsize = 1024 ) : cache = SimpleCache ( maxsize = maxsize ) def decorator ( obj ) : @ wraps ( obj ) def new_callable ( * a , ** kw ) : def create_new ( ) : return obj ( * a , ** kw ) key = ( a , tuple ( kw . items ( ) ) ) return cache . get ( key , create_new ) return new_callable return decorator
decorator that caches function calls .