code: def cache_as_field(cache_name):
      
      def cache_wrapper(func):
          @functools.wraps(func)
          def inner_wrapper(self, *args, **kwargs):
              value = getattr(self, cache_name, UndefToken)
              if value != UndefToken:
                  return value
  
              ret = func(self, *args, **kwargs)
              setattr(self, cache_name, ret)
              return ret
          return inner_wrapper
      return cache_wrapper
docs: Cache a functions return value as the field 'cache_name'.