qrisp.QuantumCircuit.to_qasm3#

QuantumCircuit.to_qasm3(formatted: bool = False, filename: str | None = None, encoding: str | None = None) str[source]#

Returns the OpenQASM 3.0 string of this QuantumCircuit.

Parameters:
formattedbool, optional

Accepted for backward compatibility with the previous Qrisp API but has no effect. The default is False.

filenamestr, optional

If provided, the QASM string is also written to this file path. The default is None.

encodingstr, optional

The file encoding to use when writing to filename. Defaults to the system’s preferred encoding. Only relevant when filename is given.

Returns:
str

The OpenQASM 3.0 string.

Examples

>>> from qrisp import QuantumCircuit
>>> qc = QuantumCircuit(2)
>>> qc.h(0)
>>> qc.cx(0, 1)
>>> print(qc.to_qasm3())
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] qb_75;
qubit[1] qb_76;
h qb_75[0];
cx qb_75[0], qb_76[0];