Skip to content

Commit 05a1efe

Browse files
committed
faster commutation
1 parent 8d8a6c5 commit 05a1efe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cirq-core/cirq/ops/pauli_string.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,8 +1395,8 @@ def inplace_after(self, ops: 'cirq.OP_TREE') -> 'cirq.MutablePauliString':
13951395
p1 = _INT_TO_PAULI_OR_IDENTITY[ps[1]]
13961396

13971397
# Kick across Paulis that anti-commute with the controls.
1398-
kickback_0_to_1 = not protocols.commutes(p0, gate.pauli0)
1399-
kickback_1_to_0 = not protocols.commutes(p1, gate.pauli1)
1398+
kickback_0_to_1 = not (identity.I in [p0, gate.pauli0] or p0 == gate.pauli0)
1399+
kickback_1_to_0 = not (identity.I in [p1, gate.pauli1] or p1 == gate.pauli1)
14001400
kick0 = gate.pauli1 if kickback_0_to_1 else identity.I
14011401
kick1 = gate.pauli0 if kickback_1_to_0 else identity.I
14021402
self.__imul__({q0: p0, q1: kick0})

0 commit comments

Comments
 (0)