diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py index f33154b758e4..5a0a325fada0 100644 --- a/qiskit/circuit/quantumcircuit.py +++ b/qiskit/circuit/quantumcircuit.py @@ -3636,11 +3636,6 @@ def add_register(self, *regs: Register | int | Sequence[Bit]) -> None: ) for register in regs: - if isinstance(register, Register) and any( - register.name == reg.name for reg in self.qregs + self.cregs - ): - raise CircuitError(f'register name "{register.name}" already exists') - if isinstance(register, AncillaRegister): for bit in register: if bit not in self._qubit_indices: diff --git a/releasenotes/notes/create-register-performance-fe392209793d151f.yaml b/releasenotes/notes/create-register-performance-fe392209793d151f.yaml new file mode 100644 index 000000000000..b2859ddb5d88 --- /dev/null +++ b/releasenotes/notes/create-register-performance-fe392209793d151f.yaml @@ -0,0 +1,7 @@ +performance: + - | + Improves runtime performance of the :py:meth:`~.QuantumCircuit.add_register()` method on + :py:class:`~.QuantumCircuit`. Consequently, this change improves performance when + creating :py:class:`~.QuantumCircuit` as well. Generally, the time complexity of + checking register name presence was reduced to :math:`O(1)` from :math:`O(n)`. This was + achieved by removing redundant error checking.