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

Fix quadratic construction time of QuantumCircuit #11517

Merged
merged 3 commits into from
Jan 10, 2024

Commits on Jan 8, 2024

  1. 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`.
    jakelishman committed Jan 8, 2024
    Configuration menu
    Copy the full SHA
    4d4bfbb View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2024

  1. Configuration menu
    Copy the full SHA
    5048d15 View commit details
    Browse the repository at this point in the history
  2. Strengthen warnings

    jakelishman committed Jan 9, 2024
    Configuration menu
    Copy the full SHA
    203a358 View commit details
    Browse the repository at this point in the history