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.
Fix quadratic construction time of
QuantumCircuit
The current implementation of `CircuitData.add_qubit` (ditto `clbit`) has linear time complexity because it reconstructs the list on each addition, while the `CircuitData.qubits` getter silently clones the list on return. This was intended to avoid inadvertant Python-space modifications from getting the Rust components out of sync, but in practice, this cost being hidden in a standard attribute access makes it very easy to introduce accidental quadratic dependencies. In this case, `QuantumCircuit(num_qubits)` and subsequent `qc.append(..., qc.qubits)` calls were accidentally quadratic in `num_qubits` due to repeated accesses of `QuantumCircuit.qubits`.
- Loading branch information
1 parent
4084382
commit 4d4bfbb
Showing
1 changed file
with
29 additions
and
14 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