qiskit/releasenotes/notes/0.24/qasm2-parser-rust-ecf6570e2...

24 lines
1011 B
YAML

---
features:
- |
A new OpenQASM 2 parser is available in :mod:`qiskit.qasm2`. This has two entry points:
:func:`.qasm2.load` and :func:`.qasm2.loads`, for reading the source code from a file and from a
string, respectively::
import qiskit.qasm2
program = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
h q[0];
cx q[0], q[1];
"""
bell = qiskit.qasm2.loads(program)
This new parser is approximately 10x faster than the existing ones at
:meth:`.QuantumCircuit.from_qasm_file` and :meth:`.QuantumCircuit.from_qasm_str` for large files,
and has less overhead on each call as well. The new parser is more extensible, customizable and
generally also more type-safe; it will not attempt to output custom Qiskit objects when the
definition in the OpenQASM 2 file clashes with the Qiskit object, unlike the current exporter.
See the :mod:`qiskit.qasm2` module documentation for full details and more examples.