How *exactly* does Python and Rust work together?

108 points SureImNoExpertBut

Hi all.

I'm an absolute Rust noob, and a self-taught Python coder. I don't work as a developer and have no CS background, just started learning Rust for fun. I recently discovered that you can integrate faster Rust programs into simpler Python scripts.

I'm curious about the underlying mechanics of this process. I understand that Python essentially serves as an interface that "glues together" multiple C++ files. So, it would make sense to me to write functions in C++ that interact with the C++ files that comprise Python. However, how does Rust achieve this? Does it convert Python objects into Rust data types? I know you can compile a Rust program into a binary that can accept and process command-line arguments. Is Python essentially doing that?

Would love to get your takes on that, and If anyone knows of any good articles on this topic, I'd be eager to read them.