openqasm3
Reference OpenQASM AST in Python
What it is and what it does
openqasm3 is a reference implementation of the OpenQASM 3 abstract syntax tree in Python, designed to help developers write compiler passes and tools for quantum programs. It provides three main components: the AST node definitions, a parser that converts OpenQASM 3 text into the tree structure, and a visitor/transformer base for traversing and modifying the AST.
The package deliberately minimizes dependencies for users who only consume the AST structure itself, with optional dependencies available for parsing functionality. It is maintained as part of the main OpenQASM project and actively developed alongside the OpenQASM 3 language specification itself, though the API is currently in early stages and not considered stable.
Use it for:
- Build compiler optimization passes that analyze and transform OpenQASM 3 quantum circuits
- Parse OpenQASM 3 source files into an in-memory representation for analysis or code generation
- Traverse and modify quantum program ASTs using visitor and transformer patterns
- Develop quantum software tools that need to understand OpenQASM 3 program structure
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a reference abstract syntax tree (AST) for OpenQASM 3 quantum programs, with parsing and AST manipulation tools for building compiler passes in Python.
Yes, if you are working with OpenQASM 3 quantum programs and need to parse or manipulate them programmatically. The low install friction and active maintenance make it a practical choice. However, be aware that the API is explicitly unstable and subject to breaking changes as the OpenQASM 3 language itself evolves—pin your version carefully in production code.
Install
openqasm3 on PyPI
pip
pip install openqasm3uv
uv add openqasm3poetry
poetry add openqasm3Installing openqasm3
Before you install
Low install friction with no runtime dependencies for basic AST consumption. Actively maintained with recent releases; note that the API is explicitly in early development and not yet stable.
License in practice
Licensed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions.
Quickstart
pip install openqasm3
import openqasm3
# Parse OpenQASM 3 text into AST
ast = openqasm3.parser.parse_file('program.qasm')
Parser functionality requires the optional 'parser' extra; install with `pip install openqasm3[parser]` to use parsing features.
Verify before relying
- Whether the AST API stability improves in future releases or remains subject to breaking changes
- Performance characteristics when working with large or complex quantum programs
Package facts
| License | Apache 2.0 Software License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 541 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 483,280/month — #6,415 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: openqasm3-1.0.1-py3-none-any.whl
Keywords: openqasm, quantum
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
openpulseOpenPulse parses and represents pulse grammar…
permissive · top 15,000 on PyPI
qiskit-qasm3-importConverts OpenQASM 3 programs (as strings) into…
permissive · top 15,000 on PyPI
oqpyOQpy generates OpenQASM 3 and OpenPulse…
permissive · top 15,000 on PyPI
astroidAstroid builds an extended abstract syntax tree…
copyleft · top 1,000 on PyPI
amazon-braket-schemasProvides serialization, deserialization, and…
permissive · top 15,000 on PyPI
qualnameProvides a `qualname()` function that emulates…
permissive · top 15,000 on PyPI
luaparserParses Lua source code into an abstract syntax…
permissive · top 15,000 on PyPI
astunparseConverts Python abstract syntax trees (ASTs)…
permissive · top 5,000 on PyPI
astorastor converts Python abstract syntax trees…
permissive · top 5,000 on PyPI
hogql-parserParses HogQL query expressions and Hog programs…
permissive · top 5,000 on PyPI