Should cirq.Moment
store operations sorted by the underlying qubits?
#4742
Labels
area/circuits
area/moments
kind/design-issue
A conversation around design
triage/accepted
A consensus emerged that this bug report, feature request, or other action should be worked on
The iteration order of operations in a
cirq.Moment
currently depends upon the order in which the operations were inserted in the moment. This can lead to cases where two momentsm1 == m2
is True but theirrepr
s and iteration order of underlying operations are not the same.The proposal is to directly store and use
sorted(self.operations, key=lambda op: op.qubits)
as the list of underlying operations in a moment to avoid such inconsistencies and uniquely define the traversal order of operations in equal moments.The text was updated successfully, but these errors were encountered: