From 415e9b7fb8baaa4a79b59be0531b1e8392ee11d2 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 22 Aug 2024 12:37:15 -0400 Subject: [PATCH] Make add_clbits() signature the same as add_qubits() At some point during the development of this PR the function signatures between `add_qubits()` and `add_clbits()` diverged between taking a `Vec>` and `&Bound`. In general they're are comprable but since we are going to be working with a `Vec<>` in the function body this is a better choice to let PyO3 worry about the conversion for us. Additionally, this is a more natural signature for rust consumption. This commit just updates `add_clbits()` to use a Vec too. --- crates/circuit/src/dag_circuit.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/circuit/src/dag_circuit.rs b/crates/circuit/src/dag_circuit.rs index e6d15ce5289b..67849a6f2281 100644 --- a/crates/circuit/src/dag_circuit.rs +++ b/crates/circuit/src/dag_circuit.rs @@ -964,9 +964,8 @@ def _format(operand): } /// Add individual qubit wires. - fn add_clbits(&mut self, py: Python, clbits: &Bound) -> PyResult<()> { - let bits: Vec> = clbits.extract()?; - for bit in bits.iter() { + fn add_clbits(&mut self, py: Python, clbits: Vec>) -> PyResult<()> { + for bit in clbits.iter() { if !bit.is_instance(imports::CLBIT.get_bound(py))? { return Err(DAGCircuitError::new_err("not a Clbit instance.")); } @@ -979,7 +978,7 @@ def _format(operand): } } - for bit in bits.iter() { + for bit in clbits.iter() { self.add_clbit_unchecked(py, bit)?; } Ok(())