code: def cached(func, instance, args, kwargs):
      
      cache = getattr(instance, "__cache", None)
      if cache is None:
          instance.__cache = cache = {}
      try:
          return cache[func]
      except KeyError:
          cache[func] = result = func(*args, **kwargs)
          return result
docs: Simple decorator to cache result of method calls without args.