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.3

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.3
File
pyoz-0.13.3-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
pyoz-0.13.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pyoz-0.13.3-cp310-abi3-manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
pyoz-0.13.3-cp310-abi3-manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
pyoz-0.13.3-cp310-abi3-macosx_13_0_x86_64.whl CPython 3.10 abi3 macOS 13.0+ x86-64 Details
pyoz-0.13.3-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.3-cp310-abi3-win_arm64.whl

Download URL pyoz-0.13.3-cp310-abi3-win_arm64.whl
Size 723.5 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
1ff553e5693db158d9b5545e8be11e9f1d21e0ffd9b28874c2c2fdee748dcd0d
BLAKE2b-256 checksum
How to use checksums
0e63b582da04dee9d7d8e04878ebae02f3811d4774d921d6cc82b5350586e0e5
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.3-cp310-abi3-win_amd64.whl

Download URL pyoz-0.13.3-cp310-abi3-win_amd64.whl
Size 757.4 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c51f16873b8fdb8565778300c89921463fb75aa9b2640b7f79548727780f7abd
BLAKE2b-256 checksum
How to use checksums
788378425edace6f6000f7422eaf48cb125783753769b0b39a8592329a8528c3
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.3-cp310-abi3-manylinux2014_x86_64.whl

Download URL pyoz-0.13.3-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
d03bfc8beb5bcb15fc237c7c167bff53ed7eec0a18e2f3419bbcd2fc2557e301
BLAKE2b-256 checksum
How to use checksums
c07c2428d6b002594b94a81addd3434aa7d145657f9c15c0a1dbe6a3798059a8
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.3-cp310-abi3-manylinux2014_aarch64.whl

Download URL pyoz-0.13.3-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
747d3d4708d97dbc39dfb1636322e9fb27dd9da98aecbd4593f788ca49112cf9
BLAKE2b-256 checksum
How to use checksums
d4642d677e1175a296efc6b83ac969e712c0c1376caabd859c051b0fa4aca4f3
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.3-cp310-abi3-macosx_13_0_x86_64.whl

Download URL pyoz-0.13.3-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
e208baede1f059b6e8e11b095f281f644293b7bf8afbc7f1aecca19bbf444b7c
BLAKE2b-256 checksum
How to use checksums
407228ec58a26bb68c13ff35a2507d80a5962828e2e7370a79272d4bab1c2710
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.3-cp310-abi3-macosx_13_0_arm64.whl

Download URL pyoz-0.13.3-cp310-abi3-macosx_13_0_arm64.whl
Size 644.3 kB
Tags CPython 3.10 abi3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
32bc4ccb1aed4e8e219bd60c5404197e9af8643298370f3b1cdfa7325e09d689
BLAKE2b-256 checksum
How to use checksums
660e392d0b9a9fdea6d0d9bf3fcbb49836a2bdbac312f28d25a98f73598efe75
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