'Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().'

def __get__(self, instance, cls=None):

    if (instance is None):
        return self
    res = instance.__dict__[self.name] = self.func(instance)
    return res
