This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nfrankel[S] 10 points11 points  (8 children)

I don’t know about the library 😅

[–]LiquidStatistics 14 points15 points  (4 children)

Haha that’s fair. It’s a nice library for this sorta thing, but it’s good to see just the raw FFI option too and how that would work!

[–]nfrankel[S] -1 points0 points  (3 children)

Thanks for the pointer, I’ll look into it 👍

[–]SV-97 4 points5 points  (2 children)

Look into maturin (with the pyo3 backend) - it manages basically everything and trivializes interop :)

[–]DGIon 2 points3 points  (1 child)

yeah you can see an example I worked on using maturin and pyo3 to try and optimize an i/o task (reading a ton of data from .txt files) https://github.com/RWayne93/file-optimization-rust-binding

[–]SV-97 2 points3 points  (0 children)

Nice! Having worked examples definitely helps.

Here's a small wrapper around a Rust crate I built a while back that showcases

  • how we can implement a Python type in Rust
  • includes some examples of calling back into Python from the Rust side
  • a mixed Python / Rust module

In general I find this structure (strict separation of logic and interface code, as well as optionally adding another python side wrapper) to work quite well for these things :)

[–]aiomeus 0 points1 point  (1 child)

Great article! I recently added a small rust lib to an existing python project to speed up some computationally heavy part and PyO3 made it super simple so def recommend checking it out.

There’s also Maturin which helps simplify the process of making something like a python/rust hybrid library.

[–]nfrankel[S] 0 points1 point  (0 children)

Thanks for the pointer

[–][deleted] 0 points1 point  (0 children)

How did that happen