From the course: Using Rust with Python

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Python calculator CLI

Python calculator CLI - Rust Tutorial

From the course: Using Rust with Python

Python calculator CLI

- [Instructor] Here's a PyO3 Rust-Python CLI project that shows the diagram of how this would work in the real world. First up, you would build the parts that you need to build in Rust. In this case, it could be the computation. So this could be anything from using third party libraries or doing MLOps code or doing some kind of custom, you know, algorithm that would be really efficient in Rust. And then in this section here, you would put that into the add function and wrap those all inside. So once you've got that, I like to have a makefile here that builds out the .so into the correct directory. And then one of my recommended best practices would be to use a library like Python Fire to just wrap it up. So you have to write really almost nothing to get your code working, and then you can use that Rust code from the terminal. So you're really combining the best of both Python and Rust. So, okay, that's enough theory. Let's get into the demo. Now if we get into this example here, we…

Contents