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.8
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.8-cp310-abi3-win_arm64.whl | CPython 3.10 | abi3 | Windows ARM64 | Details |
| pyoz-0.13.8-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| pyoz-0.13.8-cp310-abi3-manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| pyoz-0.13.8-cp310-abi3-manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| pyoz-0.13.8-cp310-abi3-macosx_13_0_x86_64.whl | CPython 3.10 | abi3 | macOS 13.0+ x86-64 | Details |
| pyoz-0.13.8-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.8-cp310-abi3-win_arm64.whl
| Download URL | pyoz-0.13.8-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 723.1 kB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0ba9d4520f381b4f45b00257b583a076a295c6c93324896a34a472bd942e47d6
|
|
BLAKE2b-256 checksum How to use checksums |
cea653080f133d5cdb7aac9a409ad712a3f2812730045036bcd4a0c4e20838d9
|
| 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.8-cp310-abi3-win_amd64.whl
| Download URL | pyoz-0.13.8-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 757.2 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d1b81932dd1ab47c5e1d919c260ce438cfe301aac0d2223638d6c24600be37ec
|
|
BLAKE2b-256 checksum How to use checksums |
3f9374c8c630c80ca06d330e8f07936c2e9e8431f96ec62e8999439e6c0bd845
|
| 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.8-cp310-abi3-manylinux2014_x86_64.whl
| Download URL | pyoz-0.13.8-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 |
657fccdf41596ae117fc1569f0565bf65864f08e97a1907e5e65ae54865cda07
|
|
BLAKE2b-256 checksum How to use checksums |
9b7d3b6f4f56574f1be69f36d4233d8263d4c490e8f8a8c722656ff75a0c155b
|
| 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.8-cp310-abi3-manylinux2014_aarch64.whl
| Download URL | pyoz-0.13.8-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 |
321452e9818b33aee3b8da3b0443fe86caebaf2926bc50ff585c6c9d9e4fc1c9
|
|
BLAKE2b-256 checksum How to use checksums |
6e560b9f52cbf05bbe930456fcb9d0e598659cd0ea3cf1e48f74f4a05681795b
|
| 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.8-cp310-abi3-macosx_13_0_x86_64.whl
| Download URL | pyoz-0.13.8-cp310-abi3-macosx_13_0_x86_64.whl |
|---|---|
| Size | 680.1 kB |
| Tags | CPython 3.10 abi3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
fd0dbe0599911ded5665a222f090f6e820f8b19efcca6c9ce29425fadddd647e
|
|
BLAKE2b-256 checksum How to use checksums |
88f4d489a53c853c269789b7a91c85003f9b15f97898754fe0bd9de2726ae2cd
|
| 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.8-cp310-abi3-macosx_13_0_arm64.whl
| Download URL | pyoz-0.13.8-cp310-abi3-macosx_13_0_arm64.whl |
|---|---|
| Size | 644.2 kB |
| Tags | CPython 3.10 abi3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9c40c9977f2f010e369b183bc2ce79d5a4cfde7e51f08c1c9dee46d63a042fef
|
|
BLAKE2b-256 checksum How to use checksums |
ebca3e1adcdabd196b77da9d402bb100ef03b1154f7e65e15d42f9e351b1393a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|