code: def memoized(maxsize=1024):
      """
      Momoization decorator for immutable classes and pure functions.
      """
      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
  
file_path: catboost/contrib/python/prompt-toolkit/py2/prompt_toolkit/cache.py
imports: from __future__ import unicode_literals
  from collections import deque
  from functools import wraps
label_desc: Use image node_id 1 for calling a global function with example usage: memoized(maxsize) and returns: decorator, new_callable, cache, obj