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

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

Download URL pyoz-0.13.6-cp310-abi3-win_arm64.whl
Size 723.1 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
f2a5ce6cce128a09a078d096663dd48af63dc28f8fbe29fbe82ea236457b7cc2
BLAKE2b-256 checksum
How to use checksums
a15a2c800b56f4cb5c1d2609628eabf97b7e5b203f92d78aa95f39bebbb9c26b
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.6-cp310-abi3-win_amd64.whl

Download URL pyoz-0.13.6-cp310-abi3-win_amd64.whl
Size 757.2 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3ddf71d588bc1fef30500dc2e440b67553095b3a49a7a64a46880682d2e36969
BLAKE2b-256 checksum
How to use checksums
5b0445b3f7f3908f789bf718aa44c7023f2e1752ae1b26bec6a25ac839fb4800
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.6-cp310-abi3-manylinux2014_x86_64.whl

Download URL pyoz-0.13.6-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
fe48363da895ba55c7b81ff0951f765b33e55701b771a97c52deb07a3ecd2414
BLAKE2b-256 checksum
How to use checksums
3842fb224d362a3ecb48a56177eeaabad8bd31653075a7cce28622568c46d6c8
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.6-cp310-abi3-manylinux2014_aarch64.whl

Download URL pyoz-0.13.6-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
a4c590747257f365fcd58e4704d2b3c5b632414dbb116bb7a68a2e2d4e54b46b
BLAKE2b-256 checksum
How to use checksums
45e648e7859b9936b125d02e5e52b6f206a9c41a252091a9e21d1afd973b3484
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.6-cp310-abi3-macosx_13_0_x86_64.whl

Download URL pyoz-0.13.6-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
929fd138fcfac2eaf38d32e20cbaa0374ce082bb3a0795fce2fb3bfa18878de0
BLAKE2b-256 checksum
How to use checksums
71e71aa3864fcb344b37665c056691475f4fe9cb580197288418a83283c48d10
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.6-cp310-abi3-macosx_13_0_arm64.whl

Download URL pyoz-0.13.6-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
8da132a9fc97941b969707ff38fa495b51c7a5fdd00b148b7d3d823f4c2dccda
BLAKE2b-256 checksum
How to use checksums
1887c7978f3286395a6607aec3a6544a1ea4291ad46581fd9d7c378c8c96b48f
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