3 ms·
Have you found it easy to write rust modules with python interfaces? What tools do you recommend?
by oofbey 1y ago
Have you found it easy to write rust modules with python interfaces? What tools do you recommend?
- ederamen 1y agoI'd be interested in this too. I know it's possible, but haven't found a good guide on how to do it well and manage the multi-lang complexity.
- sbt567 1y agoMany people use PyO3 for that
- oconnor663 1y agoPyO3 and Maturin are excellent. I've been maintaining a Python-module-written-in-Rust for several years now, and it's been quite smooth.
- the__alchemist 1y agoPyO3 + Maturn is fine, but it's a bit tedious if you have a big API. Some annoyances: - Enums with inner types require hacks - No clean way to make your Rust enums into Python enums - More boilerplate than you should have. I think I will have to write my own macros/helpers to solve. For example, you need getters and setters for each field. And the gotcha: You can't just macro them due to a PyO3 restriction. - No way to use other Python-exposed rust libs as dependencies directly. You have to re-expose everything. So, if your rust B lib depends on rust A, you will make a PyO3 Rust A package, but instead of re-using that in PyO3 Rust B, you will copy+paste your PyO3 Rust A boilerplate into PyO3 Rust B. If you're maintaining a single lib and want to expose it to Python, it's fine once you find a pattern that works. If you have a network and/or your API is large or not stable, it's a mess. (but doable)