forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate tuple-like access to
CircuitInstruction
(Qiskit#12640)
This has been the legacy path since `CircuitInstruction` was added in Qiskitgh-8093. It's more performant to use the attribute-access patterns, and with more of the internals moving to Rust and potentially needing more use of additional class methods and attributes, we need to start shifting people away from the old form.
- Loading branch information
1 parent
d518184
commit 55fb94d
Showing
5 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
releasenotes/notes/deprecate-legacy-circuit-instruction-8a332ab09de73766.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
deprecations_circuits: | ||
- | | ||
Treating :class:`.CircuitInstruction` as a tuple-like iterable is deprecated, and this legacy | ||
path way will be removed in Qiskit 2.0. You should use the attribute-access fields | ||
:attr:`~.CircuitInstruction.operation`, :attr:`~.CircuitInstruction.qubits`, and | ||
:attr:`~.CircuitInstruction.clbits` instead. For example:: | ||
from qiskit.circuit import QuantumCircuit | ||
qc = QuantumCircuit(2, 2) | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.measure([0, 1], [0, 1]) | ||
# Deprecated. | ||
for op, qubits, clbits in qc.data: | ||
pass | ||
# New style. | ||
for instruction in qc.data: | ||
op = instruction.operation | ||
qubits = instruction.qubits | ||
clbits = instruction.clbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters