I’m experimenting with different tools to write low level extensions to Python. I’ve written a bunch of extensions with PyBind11, but I really wanted to mess with Zig. I’ve been looking for an excuse for ages to try it.
Anyway, if you’re in C code, you register an extension module by using this PyMODINIT_FUNC thing like this:
pub const PyMODINIT_FUNC = @compileError("unable to translate C expr: unexpected token 'Eof'");
I’m so new to Zig that I don’t even know where to start. Did I bite off more than I could chew? Should I just go back to my previous Zigless (boring) life with C++ / PyBind11?
Also first time posting, really hope it supports markdown triple backtick.
cImport generates a @compileError when it cannot parse the definition.
Since PyMODINIT_FUNC is actually a pointer to a PyObject, the following code must work:
I’ll keep poking away and seeing if I can get my Python ext module boilerplate to do stuff. Folks clearly have linked me working examples so it’s probably just a PEBKAC error…
It would be super nice to be able to use Zig. I love the syntax, it’s so much cleaner and more modern feeling than C…
Also, even if I fail in my task and I’m stuck in C-land I absolutely intend to utilize Zig’s cross-platform compiler tooling. That right there is downright amazing.