Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify return type of DAGCircuit::control_flow_op_nodes #13892

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakelishman
Copy link
Member

Technically this is a breaking change, not because of the type change (we're returning a subset of what we previously did), but because the docstring previously explicitly said that None was used for the empty list. In practice, this is a bit of a footgun (as I found), and inconsistent with the other DAGCircuit methods. It's not clear that it has a performance advantage; technically it can save a single Python empty-list allocation (None is a singleton), but this cost is pretty trivial.

Summary

Details and comments

I'll not be distraught if we choose not to do this because it's technically a breaking change, but I can say from experience that I managed to write a buggy transpiler pass because of the unexpected behaviour here, and if not op_nodes is naturally supported on both 1.x and 2.x.

Technically this is a breaking change, not because of the type change
(we're returning a subset of what we previously did), but because the
docstring previously _explicitly_ said that `None` was used for the
empty list.  In practice, this is a bit of a footgun (as I found), and
inconsistent with the other `DAGCircuit` methods.  It's not clear that
it has a performance advantage; technically it can save a single Python
empty-list allocation (`None` is a singleton), but this cost is pretty
trivial.
@jakelishman jakelishman added Changelog: API Change Include in the "Changed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library labels Feb 19, 2025
@jakelishman jakelishman added this to the 2.0.0 milestone Feb 19, 2025
@jakelishman jakelishman requested a review from a team as a code owner February 19, 2025 18:21
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@coveralls
Copy link

Pull Request Test Coverage Report for Build 13419615561

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 3 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.006%) to 88.107%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/qasm2/src/lex.rs 2 92.23%
Totals Coverage Status
Change from base Build 13411473274: 0.006%
Covered Lines: 78349
Relevant Lines: 88925

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog mod: circuit Related to the core of the `QuantumCircuit` class or the circuit library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants