from functools import cached_property class C: @cached_property def v(self): print('compute') return 42 c = C() print(c.v); print(c.v)