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.
Rust to Python - Rust Tutorial
From the course: Using Rust with Python
Rust to Python
- [Instructor] Here we have a project that does something that is very common when you're converting between Python and Rust, which is you have a particular data type and you want to convert it into a Python data structure. So how do we do this? First up here you can see that the lib is the location where all the code is. So inside of source, lib.rs inside of a directory called data-conversion. I've got a import here that says use Py03 and there's some libraries that are imported, including the Python dictionary. Next step what we do is we have a Python function here, which is going to do the heavy lifting and we say function data types example py. And then we have a Py results object right here. And then we define our Rust types here. So we say text and this is a string. We have integer, this is i32, we have floating F64 and we have bool. Now what we do is we create a Python dictionary. So again, this is a traditional Python dictionary people are used to, but we're doing it from…
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
-