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 - 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
-
-
Introduction: Instructor45s
-
Introduction: Rust and Python5m
-
PyO3 installation4m 15s
-
(Locked)
Basic Rust library4m 46s
-
(Locked)
Rust to Python3m 33s
-
(Locked)
Rust ownership model4m 59s
-
(Locked)
Diagram of a PyO3 project3m 40s
-
(Locked)
Python calculator CLI3m 54s
-
(Locked)
PyO3 features2m 38s
-
(Locked)
PyO3 exceptions4m 21s
-
(Locked)
Call Python from Rust5m 53s
-
(Locked)
Run Python with embedded Rust4m 47s
-
(Locked)
Embedded Rust CLI diagram3m 34s
-
(Locked)
Embedded Rust CLI4m 31s
-
(Locked)
Embedded Rust CLI test4m 59s
-
(Locked)
Rust-built Python tools3m 52s
-
(Locked)
Using the Rust Ruff linter5m 15s
-
(Locked)
Using Polars in Python with Rust4m 9s
-
(Locked)
Polars CLI in Rust4m
-
(Locked)
Polars CLI test in Rust4m 21s
-
(Locked)
Polars CLI integration test3m 29s
-
(Locked)
Polars criterion benchmarking5m 39s
-