PyOZ
Zig's power meets Python's simplicity. Build blazing-fast Python extensions with zero boilerplate and zero Python C API headaches.
Documentation | Getting Started | Examples | GitHub
Quick Example
Write normal Zig code -- PyOZ handles all the Python integration automatically:
const pyoz = @import("PyOZ");
const Point = struct {
x: f64,
y: f64,
pub fn magnitude(self: *const Point) f64 {
return @sqrt(self.x * self.x + self.y * self.y);
}
};
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"),
},
.classes = &.{
pyoz.class("Point", Point),
},
});
import mymodule
print(mymodule.add(2, 3)) # 5
p = mymodule.Point(3.0, 4.0)
print(p.magnitude()) # 5.0
print(p.x, p.y) # 3.0 4.0
Features
- Declarative API -- Define modules, functions, and classes with simple struct literals
- Automatic type conversion -- Zig
i64,f64,[]const u8, structs, optionals, error unions all map to Python types automatically - Full class support --
__init__,__repr__,__add__,__iter__,__getitem__, properties, static/class methods, inheritance - NumPy integration -- Zero-copy array access via buffer protocol
- Error handling -- Zig errors become Python exceptions; custom exception types supported
- Type stubs -- Automatic
.pyigeneration for IDE autocomplete and type checking - GIL management -- Release the GIL for CPU-bound Zig code with
pyoz.releaseGIL() - Async --
awaitZig functions and methods from asyncio (built on Zig'sstd.Io), with cancellation that reaches the Zig task - Free-threading -- Runs without the GIL on free-threaded CPython (3.14t); class instances get per-object locking automatically
- Cross-class references -- Methods can accept/return instances of other classes in the same module
- Simple tooling --
pyoz init,pyoz build,pyoz develop,pyoz publish
Installation
pip install pyoz
Requires Zig 0.16.0+ and Python 3.10--3.14.
Getting Started
# 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))"
Documentation
Full documentation at pyoz.dev:
- Installation -- Setup and requirements
- Quickstart -- Your first PyOZ module in 5 minutes
- Functions -- Module-level functions, keyword arguments
- Classes -- Full class support with magic methods
- Types -- Type conversion reference
- Properties -- Computed properties and getters/setters
- Error Handling -- Zig errors to Python exceptions
- NumPy -- Zero-copy buffer protocol
- GIL -- Releasing the GIL for parallelism
- CLI Reference -- Build, develop, publish commands
- Complete Example -- Full-featured module walkthrough
License
MIT
Metadata
Release files for pyoz 0.13.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyoz-0.13.1-cp310-abi3-win_arm64.whl | CPython 3.10 | abi3 | Windows ARM64 | Details |
| pyoz-0.13.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| pyoz-0.13.1-cp310-abi3-manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| pyoz-0.13.1-cp310-abi3-manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| pyoz-0.13.1-cp310-abi3-macosx_13_0_x86_64.whl | CPython 3.10 | abi3 | macOS 13.0+ x86-64 | Details |
| pyoz-0.13.1-cp310-abi3-macosx_13_0_arm64.whl | CPython 3.10 | abi3 | macOS 13.0+ ARM64 | Details |
Total release size: 8.3 MB
Release files / pyoz-0.13.1-cp310-abi3-win_arm64.whl
| Download URL | pyoz-0.13.1-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 723.1 kB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
2ea64b78c33b0591c94453094198fd32d70fd5e86de3d51124410b1e26dfd00a
|
|
BLAKE2b-256 checksum How to use checksums |
225d89c4167e2736d64bfc2e826d5c52d5564063a4449b1f8718cc666ea36d64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyoz-0.13.1-cp310-abi3-win_amd64.whl
| Download URL | pyoz-0.13.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 757.6 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
c17318ab4d9704131cf34e639b22fbaaf44f6db38386315e412a6c09fc080d7c
|
|
BLAKE2b-256 checksum How to use checksums |
f6b5a2c7f3616eeee77a12e879444f13c3524bf50a4202f7a14a8cb184d097d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyoz-0.13.1-cp310-abi3-manylinux2014_x86_64.whl
| Download URL | pyoz-0.13.1-cp310-abi3-manylinux2014_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7e51c72875ffc2c163eef71e545d171abfd70e5ad585d1b67669d97591d8c250
|
|
BLAKE2b-256 checksum How to use checksums |
3deffcf59707517fda21ca8a37859c7ce8094e87dfe0b6695c831130d56216f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyoz-0.13.1-cp310-abi3-manylinux2014_aarch64.whl
| Download URL | pyoz-0.13.1-cp310-abi3-manylinux2014_aarch64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
31d76a52871655d95466385bd2e29cc3ffe5968fe04f75cc8b8f9e6fc6e3410c
|
|
BLAKE2b-256 checksum How to use checksums |
3543e231ef116c911cbee355d171807965cca8c5bdbef6f3e6e9a405c2de5ee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyoz-0.13.1-cp310-abi3-macosx_13_0_x86_64.whl
| Download URL | pyoz-0.13.1-cp310-abi3-macosx_13_0_x86_64.whl |
|---|---|
| Size | 680.2 kB |
| Tags | CPython 3.10 abi3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
dad33b9038c614be21f388b258049c5ce9c1a6eaf7f9fb987e29121228ee4973
|
|
BLAKE2b-256 checksum How to use checksums |
a8d0c30a31fa016a3490a7649f586f944c9632166cf218178e68fa67a9a9b1e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / pyoz-0.13.1-cp310-abi3-macosx_13_0_arm64.whl
| Download URL | pyoz-0.13.1-cp310-abi3-macosx_13_0_arm64.whl |
|---|---|
| Size | 644.6 kB |
| Tags | CPython 3.10 abi3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
580b6a7d6913e1207d570ef3bd2ef6991ef807e8bfe65d3aeed0837eba1b0af4
|
|
BLAKE2b-256 checksum How to use checksums |
e5a06538b1e0b2f4ae19695684f8d1bfa72c697a12c3ab647b32eb5cbc144c64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|