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

Merged
merged 1 commit into from
Feb 24, 2025

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.

@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

coveralls commented Feb 19, 2025

Pull Request Test Coverage Report for Build 13504499852

Details

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

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/qasm2/src/lex.rs 7 92.23%
Totals Coverage Status
Change from base Build 13503900974: 0.01%
Covered Lines: 77971
Relevant Lines: 88584

💛 - Coveralls

kevinhartman
kevinhartman previously approved these changes Feb 24, 2025
Copy link
Contributor

@kevinhartman kevinhartman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good with this change. Even though it's technically "breaking", it seems like something we can do reasonably in 2.0.

@kevinhartman kevinhartman self-assigned this Feb 24, 2025
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
Copy link
Member Author

Just rebased over #13506, since we touched similar bits around propagate_condition.

@kevinhartman kevinhartman added this pull request to the merge queue Feb 24, 2025
auto-merge was automatically disabled February 24, 2025 19:41

Pull Request is not mergeable

Merged via the queue into Qiskit:main with commit 8e6200a Feb 24, 2025
17 checks passed
@jakelishman jakelishman deleted the control-flow/op-nodes branch February 24, 2025 20:30
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.

4 participants