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

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

Download URL pyoz-0.13.0-cp310-abi3-win_arm64.whl
Size 722.6 kB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
8e85be60e249e7a55c50ccfa5ecb3485d5532f0398d39da8c8b51c2941384966
BLAKE2b-256 checksum
How to use checksums
bb47b431813085a90d3c642d1e71c9adc5bccb58b478e1b81ebb844b3452df9b
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.0-cp310-abi3-win_amd64.whl

Download URL pyoz-0.13.0-cp310-abi3-win_amd64.whl
Size 757.3 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
db1ab5e79795b219fa4a476525b2bef149ff059ac2c365a1cfcbfc601aeda230
BLAKE2b-256 checksum
How to use checksums
83270d6f808835318ee5b3c369074ce3bfb5024bce1e2578757441de6c8c802f
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.0-cp310-abi3-manylinux2014_x86_64.whl

Download URL pyoz-0.13.0-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
b49b4a650c24bfbc4533b70ee6c52bd8d8331cab0b04a3ffce2ecd0e00377a9d
BLAKE2b-256 checksum
How to use checksums
dd125abc4edf25e23c9cb9a5feaa9ab23499edeb9fc5375102711dc94d570dbc
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.0-cp310-abi3-manylinux2014_aarch64.whl

Download URL pyoz-0.13.0-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
8ed6e74788329e55893c912d883f505c90bba078da6557fc139d8eecd73ad6a3
BLAKE2b-256 checksum
How to use checksums
d90780a75a0d28017fce16dd1ff43d9d506f3d0813dabd2ab55502485da4d249
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.0-cp310-abi3-macosx_13_0_x86_64.whl

Download URL pyoz-0.13.0-cp310-abi3-macosx_13_0_x86_64.whl
Size 679.7 kB
Tags CPython 3.10 abi3 macOS 13.0+ x86-64
SHA-256 checksum
How to use checksums
49568002453ec8fe84ceb66d3b7218e387878127cef58ba9e9f329f24fea946e
BLAKE2b-256 checksum
How to use checksums
558e685a5c3edc53ac62310edb694f986b701d8c02c66b5e074829a59a2f8044
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.0-cp310-abi3-macosx_13_0_arm64.whl

Download URL pyoz-0.13.0-cp310-abi3-macosx_13_0_arm64.whl
Size 644.1 kB
Tags CPython 3.10 abi3 macOS 13.0+ ARM64
SHA-256 checksum
How to use checksums
e7c8de29586e7383e356dc37a7a9eec2a31a18b69d35be981ff2034feef6932c
BLAKE2b-256 checksum
How to use checksums
7b47ab48f47058dbce71243d876f1fb0dc7d2cdea3459318a91038faadc1c453
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