💾 Archived View for dioskouroi.xyz › thread › 29441840 captured on 2021-12-05 at 23:47:19. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
________________________________________________________________________________
I used this very guide a while ago and found it and the tools it teaches very enjoyable. Downright fun to use.
On the Rust side, I had to learn Box and RefCell to achieve my goals.
I’m glad you found it enjoyable! Hopefully it was helpful as well :-)
It's really cool how easy it is to interact with the Python environment, and that you can do it without actually writing any Python or needing a Rust compiler on the system you're using the Python package with.
The trouble, though, is I looked through the code for a bit, and maybe I'm missing something, but I don't understand why this needs to be in Rust. I'd lean against combining languages like this unless there's a clear benefit from doing so that you can't get by just writing Python.
I’m the author of the package in question, so I can try to answer that.
The first (and lazy) answer is that it was an educational exercise: I wanted to try my hand at writing in Python package in Rust, and this particular need afforded itself of me.
The second answer is that the package in question contains a (basic) parser, and it’s my opinion that Rust is _particularly_ well suited to this domain: you should ideally only write a /proc/…/maps parser exactly once, with strong modeling of all valid and invalid states. Rust gives us that strong modeling for free (to say nothing of performance and memory safety), and it binds easily to other languages.
I used inline_python once (powered by PyO3) and it was extremely easy to move some data from Rust into numpy and back. Used to double-check an algorithm.
Interesting read. If wheels existed for Ruby (maybe they do?) having an approach for things like nokogiri would probably put a dent in climate change but avoiding Swig-y recompilation during module installation
I haven’t meaningfully exercised my Ruby skills in a while, but you can probably fake a wheel-style gem by having extconf or something similar fetch an appropriate build from a server instead of performing the build locally. That would be an awful hack, which is why it wouldn’t surprise me to find out that people are doing it :-)
I've been writing Rust code that imports in Python with Pyo3 and Maturin.