BraynStorm/znpy
Write extensions modules for Python 3.7+ in Zig instead of C.
Write extensions modules for Python 3.7+ in Zig instead of C.
Simple and contrived:
const std = @import("std");
const znpy = @import("znpy");
comptime {
znpy.defineExtensionModule();
}
pub fn divide_f32_default_1(
args: struct {
a: f32,
b: f32 = 1,
},
) f32 {
return args.a / args.b;
}
Tested on Python versions: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13
Test on Numpy versions: [1.21 to 2.3] (API seems stable enough)
Supported argument types:
object.__bool__()
number
-like thingsnumber
-like thingsSupported return types:
Supports Optional[T]
on most parameters and all return types (except void, duh).
Supports converting Zig errors to Python Exceptions.
Supports keyword arguments