No project description provided
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyqbe-0.0.3-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: pyqbe-0.0.3-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 344.3 kB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51b4e28cf86c1ad91ace2e82c483151dc8f3e2081bda93ed826f2e6bbce08bc3
|
|
| MD5 |
690b89cffaeea59431622b6c0483a2c3
|
|
| BLAKE2b-256 |
91dad08e9c0664add0324e18948c3acf7fb611dc2a43470bfd594b03ff7fc22e
|
Provenance
The following attestation bundles were made for pyqbe-0.0.3-cp314-cp314-win_amd64.whl:
Publisher:
wheels.yml on Marpuriganesh/pyqbe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyqbe-0.0.3-cp314-cp314-win_amd64.whl -
Subject digest:
51b4e28cf86c1ad91ace2e82c483151dc8f3e2081bda93ed826f2e6bbce08bc3 - Sigstore transparency entry: 1614983148
- Sigstore integration time:
-
Permalink:
Marpuriganesh/pyqbe@5509ba6310e262714d3692ed0779eed3cf8d240f -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/Marpuriganesh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@5509ba6310e262714d3692ed0779eed3cf8d240f -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 203.7 kB
- Tags: CPython 3.14, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13933b00c51a9c264c827b262778a64e721d4cdb1fb260b9458f520471e57007
|
|
| MD5 |
47e19a83ed419cc2ed32363af926ad3c
|
|
| BLAKE2b-256 |
f608cefe52ddfdbb6eabcf4ac43a50afea6f9119de2442fc234c2690d8df05cd
|
Provenance
The following attestation bundles were made for pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
wheels.yml on Marpuriganesh/pyqbe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyqbe-0.0.3-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
13933b00c51a9c264c827b262778a64e721d4cdb1fb260b9458f520471e57007 - Sigstore transparency entry: 1614983150
- Sigstore integration time:
-
Permalink:
Marpuriganesh/pyqbe@5509ba6310e262714d3692ed0779eed3cf8d240f -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/Marpuriganesh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@5509ba6310e262714d3692ed0779eed3cf8d240f -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 162.7 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecbc81c6765969d8acf42e8f6fe737234877e74ada4cf2cc805f9ba38ba80a29
|
|
| MD5 |
8760078825767a0d592cdfec56ae0f03
|
|
| BLAKE2b-256 |
094d6896b8fb28bed4fd529b44d5f5d8f86c1dd51e3915f87dc3aafa40f10781
|
Provenance
The following attestation bundles were made for pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on Marpuriganesh/pyqbe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyqbe-0.0.3-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
ecbc81c6765969d8acf42e8f6fe737234877e74ada4cf2cc805f9ba38ba80a29 - Sigstore transparency entry: 1614983149
- Sigstore integration time:
-
Permalink:
Marpuriganesh/pyqbe@5509ba6310e262714d3692ed0779eed3cf8d240f -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/Marpuriganesh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@5509ba6310e262714d3692ed0779eed3cf8d240f -
Trigger Event:
push
-
Statement type: