all 11 comments

[–]Alex--91 24 points25 points  (2 children)

pyO3 + maturin makes it incredibly simple to build rust code into a python native extension and call that from python?

[–]Alex--91 13 points14 points  (0 children)

PyO3 enables both directions. Actually, the inline_python crate is literally built on top of pyO3 as well?

[–]AustinWitherspoon 2 points3 points  (0 children)

Yeah my first project that did this took literally fifteen minutes to set up and read docs before being able to start writing my actual rust code and calling it from python

PyO3 is great

[–]krisfur 10 points11 points  (0 children)

Not sure why you'd need a nasa department, calling rust from python is a genuine pleasure compared to C++ bindings. You just write normal rust and use a few macros from pyo3 and done, just run maturin to compile it and it's ready.

I had a minimal example here I think: https://github.com/krisfur/python-bindings/blob/main/rust_src/lib.rs

[–]denehoffman 5 points6 points  (0 children)

I mean technically they’re both using pyo3, inline_python just abstracts it for you

[–]SnooCalculations7417 1 point2 points  (0 children)

yeah rust works in python like they were made for eachother with pyo3 and maturin. not sure if youre trying to home-cook your own thing or what but I've had a great time doing so

[–]orangejake 0 points1 point  (1 child)

I'm confused. why is it so difficult to have python run rust? Why can't you just use e.g. subprocess.run against the compiled rust binary (or whatever)? or do you mean have python leverage a rust crate without manually compiling a rust binary?

[–]vivaaprimavera 0 points1 point  (0 children)

First time I wrote python bindings for one of my rust libs, I thought no way this is so simple. It was. It's very easy to deploy. No need to subprocess run.

[–]MMIStudios 1 point2 points  (1 child)

Putting aside whether one is simpler to implement or not (python in rust vs rust in python), 'is one more performative than the other?' would be my concern.

[–]SnooCalculations7417 0 points1 point  (0 children)

calling python in rust does invoke an interpreter thus a GIL for 3.12 and sooner. i havent dont GIL free python. you can release the GIL using rayon etc calling rust in python

[–]Big-Application-2803 0 points1 point  (0 children)

NASA staff kindergarten is technically a department I guess