This recreates the entire dict (which could be 100s of qubits + clbits) on every lookup.
I actually expected it to have more of an impact on transpiler performance, but it seems like we only have a couple of transpiler passes that touch them - the disjoint utils and the "remove final X" passes. I think those are sufficient non-critical we can ignore it for this first PR, but it's definitely a performance pitfall we should rectify for user passes.
At the moment, the Rust-space input_map and output_map properties recreate Python dictionaries on every access, meaning operations like [dag.input_map[qubit] for qubit in dag.qubits] have suddenly become quadratic in the number of qubits, rather than linear. This doesn't bite us too much in practice in the transpiler immediately, but it's absolutely a performance pitfall waiting to happen in the current structure.
I actually expected it to have more of an impact on transpiler performance, but it seems like we only have a couple of transpiler passes that touch them - the disjoint utils and the "remove final X" passes. I think those are sufficient non-critical we can ignore it for this first PR, but it's definitely a performance pitfall we should rectify for user passes.
_Originally posted by @jakelishman in https://github.com/Qiskit/qiskit/pull/12550#discussion_r1717036989_
At the moment, the Rust-space
input_map
andoutput_map
properties recreate Python dictionaries on every access, meaning operations like[dag.input_map[qubit] for qubit in dag.qubits]
have suddenly become quadratic in the number of qubits, rather than linear. This doesn't bite us too much in practice in the transpiler immediately, but it's absolutely a performance pitfall waiting to happen in the current structure.