-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Python 3.8 now has a functools.cached_property
from functools import cached_property
class Foo:
def __init__(self):
self._x = 0
@cached_property
def x(self):
print("Increment x!")
return self._xCreate a new foo:
>>> foo = Foo()
>>> foo.x
Increment x!
1
>>> foo.x
1The cache can be invalidated with:
>>> del foo.x
>>> foo.x
Increment x!
2Metadata
Metadata
Assignees
Labels
No labels