Skip to main content

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 .pyi generation for IDE autocomplete and type checking
  • GIL management -- Release the GIL for CPU-bound Zig code with pyoz.releaseGIL()
  • Async -- await Zig functions and methods from asyncio (built on Zig's std.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:

License

MIT

Metadata

Release files for pyoz 0.13.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pyoz 0.13.2
File
pyoz-0.13.2-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
pyoz-0.13.2-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pyoz-0.13.2-cp310-abi3-manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
pyoz-0.13.2-cp310-abi3-manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
pyoz-0.13.2-cp310-abi3-macosx_13_0_x86_64.whl CPython 3.10 abi3 macOS 13.0+ x86-64 Details
pyoz-0.13.2-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.2-cp310-abi3-win_arm64.whl

Download URL pyoz-0.13.2-cp310-abi3-win_arm64.whl
Size 723.2 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
c4519a656fd5893c9a4eb73a3b592187e77a23dfb744ce07128f6d31a8bc45ad
BLAKE2b-256 checksum
How to use checksums
4770147578fb40e95050f52cf98d1bf52a482a60d7efda81520e924620eeeac3
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.2-cp310-abi3-win_amd64.whl

Download URL pyoz-0.13.2-cp310-abi3-win_amd64.whl
Size 757.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0b9c25f0298d6fe62191ae4210a7e7f3bc303a322f42457125853807c7439c73
BLAKE2b-256 checksum
How to use checksums
5f1466aac7d38470f6fbdf77ede4c8be19a7a46a71c17debf0b188a87f9c3717
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.2-cp310-abi3-manylinux2014_x86_64.whl

Download URL pyoz-0.13.2-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
0b5b58a542f690fac15b478e49fad983ea0dfe38e222cf6f1cc66631f53dc135
BLAKE2b-256 checksum
How to use checksums
2e88d7b49aa8c36a495fd381987f2cc78615a458336182d9f49d31969c470744
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.2-cp310-abi3-manylinux2014_aarch64.whl

Download URL pyoz-0.13.2-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
2b0aec013d294f9779c246fba599eaab13fc259fec5c126b30d20509a6436ffb
BLAKE2b-256 checksum
How to use checksums
28116055aa6d1c96f58f418709ff380a83ad835a858feb8c32197fe386fa89f5
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.2-cp310-abi3-macosx_13_0_x86_64.whl

Download URL pyoz-0.13.2-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
a6b5729ec5c8c2c2bf1bf17f9cc56c58bc7a537405ce362c610896faf0a5165e
BLAKE2b-256 checksum
How to use checksums
e0a60398b123d5bf6f0570533352b7ce26d4a1442fab25144e090d081d4deeea
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.2-cp310-abi3-macosx_13_0_arm64.whl

Download URL pyoz-0.13.2-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
6e346d668ef2ecd1d08f2c721f523f7d0370cdf524f861c9abdcc46018485607
BLAKE2b-256 checksum
How to use checksums
0502bf37d25cd32107a43675461ffee055ba63e6766a1372ea01b3c5217821c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page