Zig's power meets Python's simplicity.
Build blazing-fast Python extensions with zero boilerplate and zero Python C API headaches.
const pyoz = @import("PyOZ");
fn add(a: i64, b: i64) i64 {
return a + b;
}
pub const Module = pyoz.module(.{
.name = "mymodule",
.funcs = &.{
pyoz.func("add", add, "Add two numbers"),
},
});import mymodule
print(mymodule.add(2, 3)) # 5- Declarative API - Define modules, functions, and classes with simple struct literals
- Automatic Type Conversion - Zig types map naturally to Python types
- Full Class Support - Magic methods, operators, properties, inheritance
- NumPy Integration - Zero-copy array access
- Error Handling - Zig errors become Python exceptions
- Async -
awaitZig functions from asyncio, built on Zig'sstd.Io, with real cancellation - Free-Threading - Runs without the GIL on free-threaded CPython (3.14t), with per-object locking
- Type Stubs - Automatic
.pyigeneration for IDE support - Simple Tooling -
pyoz init,pyoz build,pyoz publish
pip install pyozOr download a prebuilt binary from GitHub Releases, or build from source:
git clone https://github.com/pyozig/PyOZ.git
cd PyOZ
zig build cli# Create a new project
pyoz init myproject
cd myproject
# Build and install for development
pyoz develop
# Test it
python -c "import myproject; print(myproject.add(1, 2))"Full documentation available at pyoz.dev
- Installation
- Quickstart
- Functions
- Classes
- NumPy Integration
- Error Handling
- Async
- Free-Threading
- CLI Reference
Coming from PyOZ 0.12? See Upgrading to 0.13: Zig 0.16, Python 3.10+, and a few build.zig edits.
- Zig 0.16.x (Zig changes incompatibly between minor releases)
- Python 3.10 - 3.14
MIT License - see LICENSE for details.
Contributions welcome! Please open an issue or submit a PR.