Remove redundant name check when adding QuantumCircuit registers. - #16678
Merged
Conversation
QuantumCircuit.QuantumCircuit registers.
davidfcohen
marked this pull request as ready for review
July 28, 2026 19:55
Collaborator
|
One or more of the following people are relevant to this code:
|
raynelfss
reviewed
Jul 28, 2026
raynelfss
left a comment
Contributor
There was a problem hiding this comment.
This is a good start. Thank you for being so steadfast.
The fix itself is good. However, there are some nuances I pointed out during the review here.
You may also want to drop the "[WIP]" from PR title.
QuantumCircuit registers.QuantumCircuit registers.
raynelfss
reviewed
Jul 29, 2026
raynelfss
left a comment
Contributor
There was a problem hiding this comment.
This is about ready to merge. I have a couple formatting suggestions for your release note here.
…f.yaml Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>
Co-authored-by: Raynel Sanchez <87539502+raynelfss@users.noreply.github.com>
raynelfss
approved these changes
Jul 29, 2026
raynelfss
left a comment
Contributor
There was a problem hiding this comment.
This LGTM, thank you the quick turnaround.
raynelfss
enabled auto-merge
July 29, 2026 14:51
Contributor
|
@davidfcohen quick follow up note: it seems the error triggered now has a word repetition/typo, could we fix that while we're at it? from qiskit import QuantumCircuit, QuantumRegister
qr1 = QuantumRegister(1, "a")
qr2 = QuantumRegister(1, "a")
qc = QuantumCircuit(qr1, qr2)gives now (the "already exists" is duplicated) |
3 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
QuantumCircuitwrapsRegisterDataon the Rust side.RegisterData::add_registerreturns theRegisterAlreadyExistswhen the name is in use. This error is properly raised on the Python side without manual checking.The error is handled on the Rust side; thus, the check is redundant in the Python code. I removed the redundant check in
qiskit/circuit/quantumcircuit.py.Generally, the overall time complexity of checking whether a given register name exists was reduced from O(n) to O(1).
Fix #7133
Performance
AI/LLM disclosure