pyqbe
Python bindings for QBE, a compiler backend that generates optimized assembly. Pass QBE IR as a string, get assembly back — no external QBE binary needed.
Note: This is a hobby project.
What is this?
QBE is a small, fast compiler backend (think LLVM but ~10k lines of C). pyqbe wraps it as a Python package so you can generate assembly programmatically without shelling out to a binary.
import pyqbe
ir = """
function w $add(w %a, w %b) {
@start
%c =w add %a, %b
ret %c
}
"""
asm = pyqbe.compile(ir)
print(asm)
Why?
If you're building a compiler, DSL, or code generation tool in Python, you need a backend. QBE gives you optimized assembly for free — pyqbe makes it accessible from Python without any system dependencies.
Targets
QBE supports:
amd64— Linux (SysV ABI) and macOSarm64— Linux and macOS (Apple Silicon)riscv64— Linuxamd64_win— Windows (64-bit, requires UNIX toolchain)
Installation
pip install pyqbe
From source
Requires a C compiler and g++ with pybind11.
git clone --recurse-submodules https://github.com/Marpuriganesh/pyqbe
cd pyqbe
pip install .
--recurse-submodulesis required — QBE is included as a git submodule.
Status
Early development. API is not stable.
- QBE as git submodule
-
wrapper/qbe_api.c— FILE* shim + C entry point -
wrapper/binding.cpp— pybind11 glue -
meson.build— build config - GitHub Actions + cibuildwheel for prebuilt wheels
- Windows scenario (deferred)
How it works
QBE's parse() function takes a FILE*. pyqbe wraps this with a thin shim that turns a Python string into an in-memory FILE* (fmemopen on Linux/macOS, tmpfile fallback on Windows), calls QBE's internals directly, and captures the assembly output — all in-process.
Python string (QBE IR)
↓
string_to_file() ← FILE* shim
↓
qbe parse() + emit() ← QBE internals
↓
assembly string
Related
- QBE — the compiler backend this wraps
- LowPy — systems programming language using pyqbe as its backend
License
QBE is MIT licensed. pyqbe wrapper code is also MIT licensed.
Metadata
Release files for pyqbe 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyqbe-0.0.3-cp314-cp314-win_amd64.whl | CPython 3.14 | CPython 3.14 | Windows x86-64 | Details for pyqbe-0.0.3-cp314-cp314-win_amd64.whl |
| pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details for pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
| pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 11.0+ ARM64 | Details for pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl |
Total release size: 710.7 kB
Release files / pyqbe-0.0.3-cp314-cp314-win_amd64.whl
| Download URL | pyqbe-0.0.3-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 344.3 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
51b4e28cf86c1ad91ace2e82c483151dc8f3e2081bda93ed826f2e6bbce08bc3
|
|
BLAKE2b-256 checksum How to use checksums |
91dad08e9c0664add0324e18948c3acf7fb611dc2a43470bfd594b03ff7fc22e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logRelease files / pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 203.7 kB |
| Tags | CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
13933b00c51a9c264c827b262778a64e721d4cdb1fb260b9458f520471e57007
|
|
BLAKE2b-256 checksum How to use checksums |
f608cefe52ddfdbb6eabcf4ac43a50afea6f9119de2442fc234c2690d8df05cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logRelease files / pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 162.7 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ecbc81c6765969d8acf42e8f6fe737234877e74ada4cf2cc805f9ba38ba80a29
|
|
BLAKE2b-256 checksum How to use checksums |
094d6896b8fb28bed4fd529b44d5f5d8f86c1dd51e3915f87dc3aafa40f10781
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logSecurity for pyqbe 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 3 files in this release have been uploaded with provenance metadata.
Attestation for pyqbe-0.0.3-cp314-cp314-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.