Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix quadratic dependency in
QuantumCircuit.add_bits
(Qiskit#11546)
This is in the Python space component only. When `add_bits` is called many times, it constructs as temporary set of the union of all qubits and clbits present in the circuit in order to calculate an intersection with the input. This causes the method to be linear in the number of bits already present in the circuit, whereas it should be amortised linear in the _to be added_. This commit fixes the intersection to be a manual calculation that does not construct three temporary set objects, removing the quadratic cost.
- Loading branch information