Learn extra at:
const py = @import("pydust");
pub fn howdy() !py.PyString {
return strive py.PyString.create("Hiya!");
}
comptime {
py.rootmodule(@This());
}
Import the compiled module into Python, run its howdy
methodology, and also you’ll get again a Python string with the textual content Hiya!
. Capabilities, lessons and sophistication cases, exceptions, the Python buffer protocol (for zero-copy reminiscence entry), and suspending the GIL are all obtainable via Pydust.
Pydust at present has a number of limitations. The largest and most problematic is that it at present solely helps as much as Zig model 0.11. The event of Pydust to help future variations of Zig additionally seems to be stalled. An open issue on GitHub tracks efforts so as to add help for the most recent variations of Zig. One other attainable limitation, relying on the way you develop with Python, is Pydust’s dependency on the Poetry project management system. For those who don’t already use Poetry, you’ll have to retool your workflow to set issues up correctly.
Conclusion
Python has been round for many years, with many firmly established behaviors that aren’t going wherever. Zig is a younger language, and growing quickly, with loads of room for change. The 2 complement one another greater than they compete, and we’ve solely began seeing all of the methods they’ll work collectively.