quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.28k stars 1.02k forks source link

Replace _compat.cached_property with functools.cached_property #6395

Closed pavoljuhas closed 10 months ago

pavoljuhas commented 10 months ago

Description of the issue

cirq uses an internal version of cached_property defined here to support earlier versions of Python.

https://github.com/quantumlib/Cirq/blob/d33b1a71ac9721e762a2fa1b9e9871edfe187a3c/cirq-core/cirq/_compat.py#L64-L67

As of #6167 we require Python 3.9 which is guaranteed to have functools.cached_property.

We can therefore replace all instances of _compat.cached_property with functools.cached_property and remove the cached_property definition from the _compat.py.

Cirq version

1.4.0 at d33b1a71ac9721e762a2fa1b9e9871edfe187a3c

Josha91 commented 10 months ago

I opened a PR for this: https://github.com/quantumlib/Cirq/pull/6398.

I closed the first one because it was committed with the wrong e-mail address (and making a dummy commit with the right e-mail still failed the CLA, so I figured opening a new PR was simpler).