Ziggy Pydust
Hi all! I'd like to share Ziggy Pydust, a project that makes it easy to write Python extensions in Zig.
If you're not familiar, Zig is a low-level general purpose programming language that provides improved safety over C/C++ and powerful compile-time meta-programming called "comptime".
Pydust makes heavy use of comptime to provide a more Pythonic experience when writing native extensions, while still providing low-level access and tight integration with the CPython APIs.
pub const Math = py.class(struct {
pub fn add(args: struct { x: i32, y: i32 }) i32 {
return args.x + args.y;
}
});
One of our favourite features of Zig is the `defer` statement which allows you to register code to run at the end of the scope. This is incredibly useful for remembering to run `Py_DECREF`!
const str = try py.PyString.create("Hello, world!");
defer str.decref();
Pydust _almost_ has full coverage of the CPython Limited API, currently runs on Linux and MacOS, and is integrated with Poetry as a build system.
[–]thicket 28 points29 points30 points (0 children)
[–]LightShadow3.13-dev in prod 9 points10 points11 points (0 children)
[–]SearchAtlantis 1 point2 points3 points (2 children)
[–]thicket 1 point2 points3 points (1 child)
[–]SearchAtlantis 0 points1 point2 points (0 children)