Skip to content

Simplify return type of DAGCircuit::control_flow_op_nodes#13892

Merged
kevinhartman merged 1 commit into
Qiskit:mainfrom
jakelishman:control-flow/op-nodes
Feb 24, 2025
Merged

Simplify return type of DAGCircuit::control_flow_op_nodes#13892
kevinhartman merged 1 commit into
Qiskit:mainfrom
jakelishman:control-flow/op-nodes

Conversation

@jakelishman
Copy link
Copy Markdown
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: Changed Add a "Changed" entry in the GitHub Release 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
Copy Markdown
Collaborator

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

  • @Qiskit/terra-core

@coveralls
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
@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: Changed Add a "Changed" entry in the GitHub Release 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