code: 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
docs: Momoization decorator for immutable classes and pure functions.