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.
Basic Rust library - Rust Tutorial
From the course: Using Rust with Python
Basic Rust library
- [Instructor] Here we have a project that mixes Python and Rust. I'm using Pi 03 here. And the basic structure is that you have a source that's created here automatically when you do an init, and it creates a library file for you. So it's really set up for you to build something in Rust and then exporting that into Python. So let's go ahead and first take a look at the function here. So why would we want to do something like this? If you needed to build some really computational expensive or maybe memory expensive code, this would be a great way to do it, is to build it in Rust and export it into Python. We can see here that we're using Pi function and then there's a Rust function using FN and calculate Pi. So what happens here is you can pass in how many digits of Pi you want, and it shows you that it returns back a Pi result F64. So we say let mut pi. So there's a mutable variable defined, and then basically for every one of the iterations, so essentially the count of iterations…
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
-