diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py index 698f04b8513b..52b709d78350 100644 --- a/qiskit/circuit/quantumcircuit.py +++ b/qiskit/circuit/quantumcircuit.py @@ -1955,7 +1955,9 @@ def add_register(self, *regs: Register | int | Sequence[Bit]) -> None: def add_bits(self, bits: Iterable[Bit]) -> None: """Add Bits to the circuit.""" - duplicate_bits = set(self._qubit_indices).union(self._clbit_indices).intersection(bits) + duplicate_bits = { + bit for bit in bits if bit in self._qubit_indices or bit in self._clbit_indices + } if duplicate_bits: raise CircuitError(f"Attempted to add bits found already in circuit: {duplicate_bits}")