Re:Uv is the best thing to happen to the Python ecosystem in...
by oofbey on Wednesday October 29, 2025 @06:17PM
(#45753812)
Have you found it easy to write rust modules with python interfaces? What tools do you recommend?
[ Parent
| on HN ]
Re:Uv is the best thing to happen to the Python ecosystem in...
by ederamen on Wednesday October 29, 2025 @10:49PM
(#45755920)
I'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.
Re:Uv is the best thing to happen to the Python ecosystem in...
by sbt567 on Wednesday October 29, 2025 @11:04PM
(#45755999)
Many people use PyO3 for that
Re:Uv is the best thing to happen to the Python ecosystem in...
by oconnor663 on Wednesday October 29, 2025 @11:21PM
(#45756093)
PyO3 and Maturin are excellent. I've been maintaining a Python-module-written-in-Rust for several years now, and it's been quite smooth.
Re:Uv is the best thing to happen to the Python ecosystem in...
by the__alchemist on Thursday October 30, 2025 @10:58AM
(#45760771)
PyO3 + 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)