Skip to content

AbstractCircuit.freeze should not reallocate moments #5816

@maffoo

Description

@maffoo

Description of the issue

When freezing circuits, Moment instances should be reused since they are immutable. This was previously the case, but seems to have changed recently (possibly due to #5332).

How to reproduce the issue

In [1]: q = cirq.q(0)

In [2]: c = cirq.Circuit(cirq.X(q), cirq.measure(q))

In [3]: f = c.freeze()

In [4]: [mc is fc for mc, fc in zip(c, f)]
Out[4]: [False, False]

Cirq version

1.1.0.dev20220801180412

Metadata

Metadata

Assignees

Labels

area/circuitsgood first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/bug-reportSomething doesn't seem to work.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions