Skip to content

PyOZ

Python extensions in Zig, made easy

GitHub Python Zig License


Zig's power meets Python's simplicity.
Build blazing-fast extensions with zero boilerplate and zero Python C API headaches.

Get Started View on GitHub


  • High Performance


    Native Zig code compiles to optimized machine code. No GC overhead, predictable performance.

  • Type Safe


    Zig's compile-time checks catch bugs before runtime. PyOZ adds Python type safety on top.

  • Simple API


    Declarative module definitions. Just write Zig functions - PyOZ handles the bindings.

  • Full Python Support


    Classes, magic methods, properties, NumPy arrays, enums, exceptions, async (await), and free-threaded Python.


Upgrading from 0.12?

PyOZ 0.13 requires Zig 0.16 and Python 3.10+. See Upgrading to 0.13.

Quick Example

const pyoz = @import("PyOZ");

fn add(a: i64, b: i64) i64 {
    return a + b;
}

pub const MyModule = pyoz.module(.{
    .name = "mymodule",
    .funcs = &.{
        pyoz.func("add", add, "Add two numbers"),
    },
});
import mymodule
print(mymodule.add(2, 3))  # 5

Comparison

PyOZ PyO3 Cython
Language Zig Rust Python/C
API Style Declarative Macro-based Mixed syntax
Build Setup Simple Maturin/setuptools setuptools
C Library Interop Seamless Via unsafe/bindgen Native
Compile Time Fast Slow Medium
Cross-Compile Built-in Via cross/cargo Complex
NumPy Support Zero-copy Via crate Native
Async Support Yes (std.Io) Yes Limited
Free-Threading Yes (auto-locking) Yes Experimental
Ecosystem Growing Mature Mature