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

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

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

Download URL pyoz-0.13.7-cp310-abi3-win_amd64.whl
Size 757.2 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1e2b2e6a41668e3d468fc6a01bc73435c35fe3140a691283b06a8b3191c1b706
BLAKE2b-256 checksum
How to use checksums
82a60959ad3bd618ca073696e4c148d1b9b66e898fd0c479d814ce57d2567c21
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.7-cp310-abi3-manylinux2014_x86_64.whl

Download URL pyoz-0.13.7-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
699d986789212386918a32c92d4054ac5002b478ee2f21ffe07971499b519da1
BLAKE2b-256 checksum
How to use checksums
7b6521fca84b945676631e086824e1e38aee59ec32f951fe9f181224cbdc9995
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.7-cp310-abi3-manylinux2014_aarch64.whl

Download URL pyoz-0.13.7-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
a60e48bc543b9075df50ac203d997c97b8e27139856befc553f3360c3483267c
BLAKE2b-256 checksum
How to use checksums
9777fea5ac540dabc655e12ed3ec1d1ca74af7c4a01477dc3f9134d9d2b96dde
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.7-cp310-abi3-macosx_13_0_x86_64.whl

Download URL pyoz-0.13.7-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
bbc436113d3a72c1141eeb44b800707c97825ea1aa5e99b9b4519395218987cc
BLAKE2b-256 checksum
How to use checksums
9c6530c484a178181796df25754b7745408435dd310fae78f484bd310926b41f
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.7-cp310-abi3-macosx_13_0_arm64.whl

Download URL pyoz-0.13.7-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
7a7f986c7217543887bb0f6982e4b60444e8786f6521fd75d334fba75dd60693
BLAKE2b-256 checksum
How to use checksums
4ed50bc765be27aab455fde4fdfacf9f8a99cf231e0aa8ca2b03580d63ac9740
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