return None
// The function is called only once per instance for loading the first time
value = self.fct(instance)
setattr(instance, self.fct.__name__, value) // Overwrite the descriptor
return value
After Change
if self.fget is None:
raise AttributeError("unreadable attribute")
attr = "__cached_" + self.fget.__name__
cached = getattr(obj, attr, None)
if cached is None:
cached = self.fget(obj)
setattr(obj, attr, cached)
return cached