We often reuse instances of objects with value semantics, and in such cases equality checking can be short-circuited by first checking for object identity before falling back to actually comparing the values of two objects. This is particular beneficial if we actually take care to reuse instances, which is something we should consider doing more generally to avoid object allocation and repeated computation of various properties such as hashes (see https://github.com/quantumlib/Cirq/pull/6371).
We often reuse instances of objects with value semantics, and in such cases equality checking can be short-circuited by first checking for object identity before falling back to actually comparing the values of two objects. This is particular beneficial if we actually take care to reuse instances, which is something we should consider doing more generally to avoid object allocation and repeated computation of various properties such as hashes (see https://github.com/quantumlib/Cirq/pull/6371).