-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functools.cached_property
backport
#5031
Conversation
Does doing something like: @property
@functools.lru_cache(maxsize=None)
def thing(x):
stuff(x) not work ? |
@MichaelBroughton, no, that doesn't work generally because it it requires all parameters to be hashable, including |
Fair enough. Last question: Why should it be Cirq's responsibility to provide this wrapper for |
Agree we shouldn't export this at the top level, that's why I put it in |
The [`@functools.cached_property`](https://docs.python.org/3/library/functools.html#functools.cached_property) decorator is really useful but not currently available in cirq since it was introduced in python 3.8 but we still support python 3.7. This adds `backports.cached_property` to make cached properties available in python 3.7, using import logic in `cirq._compat` to get it from the standard library or backport module, as needed.
The [`@functools.cached_property`](https://docs.python.org/3/library/functools.html#functools.cached_property) decorator is really useful but not currently available in cirq since it was introduced in python 3.8 but we still support python 3.7. This adds `backports.cached_property` to make cached properties available in python 3.7, using import logic in `cirq._compat` to get it from the standard library or backport module, as needed.
The [`@functools.cached_property`](https://docs.python.org/3/library/functools.html#functools.cached_property) decorator is really useful but not currently available in cirq since it was introduced in python 3.8 but we still support python 3.7. This adds `backports.cached_property` to make cached properties available in python 3.7, using import logic in `cirq._compat` to get it from the standard library or backport module, as needed.
The
@functools.cached_property
decorator is really useful but not currently available in cirq since it was introduced in python 3.8 but we still support python 3.7. This addsbackports.cached_property
to make cached properties available in python 3.7, using import logic incirq._compat
to get it from the standard library or backport module, as needed.