Outline updated November 2026
Rust for Python Programmers
Class Duration
21 hours of live training delivered over 3-5 days to accommodate your scheduling needs.
Student Prerequisites
- Strong working proficiency in Python
- Comfort with packaging (pip, uv, poetry), virtual environments, and the command line
- Familiarity with type hints and
mypy/pyrightis helpful but not required - No prior Rust experience required
Target Audience
Python developers and ML or data engineers adding Rust for hot paths, native extensions, async services, or CLIs. Teams that only want to speed up existing Python code can look at High-Performance Python with Rust. Teams continuing on can move to Memory-Safe Programming with Rust and then Rust Parallel Programming.
Description
This course teaches working Rust to Python developers. Each concept is taught against its Python equivalent. Students compare ownership with reference counting, compiler-checked types with type hints, and Result with exceptions. They also compare traits with protocols and Tokio with asyncio. The course ends by moving a profiled Python hot path into a PyO3 extension and packaging it as a wheel with maturin.
Learning Outcomes
- Write idiomatic Rust using ownership, borrowing, and lifetimes.
- Map common Python idioms to Rust.
- Build a CLI or library crate with Cargo.
- Model data with structs, enums, and pattern matching.
- Use traits and generics where Python uses protocols.
- Handle errors with
Result<T, E>and?instead of exceptions. - Compare threads, Rayon, and Tokio with Python's concurrency options.
- Build a PyO3 extension with maturin and ship it as a wheel.
- Check AI-generated Rust with the compiler, clippy, and tests.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples.
Software Requirements
A free GitHub account, the current stable Rust toolchain via rustup (2024 edition), Python 3.12 or later with uv or pip, maturin, Visual Studio Code or another supported editor with the rust-analyzer and Python extensions, and an AI coding assistant of choice (GitHub Copilot, Cursor, or Claude Code). A cloud-based environment can be provided if local installation is restricted.
Training Topics
Introduction: Rust from a Python Perspective
- Where Rust fits next to Python
- What the current edition changed
- Compiled vs. interpreted
- Static vs. dynamic typing
- crates.io, lib.rs, and docs.rs
Toolchain, Cargo, and Crates
- Installing Rust with
rustup cargovs. pip, poetry, and uvCargo.tomlvs.pyproject.tomlCargo.lockvs. Python lock filescargo new,cargo run,cargo build,cargo test- rust-analyzer in VS Code, RustRover, and Zed
- Popular crates such as
serdeandtokio
Rust vs. Python: A Working Map
- Static types vs. type hints
- Ownership vs. reference counting
ResultandOptionvs. exceptions andNone- Iterators vs. generators
- Structs and
implvs. dataclasses - Traits vs. protocols and duck typing
- Crates and
modvs. packages - The GIL and free-threaded Python
- Tokio vs. asyncio
Types, Control Flow, and Functions
- Sized integers vs. Python's
int - Integer overflow behavior
- Immutability,
mut, and shadowing - Constants and statics
if/elseas expressionsloop,while, andforletchains inifandwhile- Closures and capture modes
- Modules, visibility, and
use - Common built-in macros
Ownership and Borrowing
- Ownership vs. Python name binding
- Borrowing with
&Tand&mut T - Lifetimes and the borrow checker
Box,Rc, andArcDropvs. context managers- Shared mutable state and aliasing
- Cloning to silence the compiler
Strings, Collections, and Iterators
Stringvs.&str- Vectors, slices, and arrays vs. lists
- Maps and sets vs.
dictandset - Iterator combinators vs. comprehensions
- Iterators vs.
itertools
Enums, Structs, and Pattern Matching
- Tuples and tuple structs
- Structs and constructors vs.
__init__ - Enums with data vs.
Enumclasses Option<T>andResult<T, E>matchvs. Python'smatchstatement- Destructuring, guards, and exhaustiveness
- The newtype pattern
Traits and Generics
- Defining and implementing traits
- Derived traits vs. dunder methods
- Trait objects with
dyn Trait - Generics, bounds, and
whereclauses - Static vs. dynamic dispatch
Error Handling
?vs.try/except- Error enums with
thiserror - Application errors with
anyhow - When to panic
Concurrency and Async
- Threads,
Send, andSync Arc,Mutex, and channelsrayonvs.multiprocessing- Async/await from an asyncio perspective
- Tokio,
tokio::select!, andJoinSet - HTTP with
reqwestandserde
Tests, Documentation, and Quality
- Rust tests vs. pytest
- Doc tests vs. doctest
- Documentation with
rustdoc clippyandrustfmtvs. Ruff
Python Extensions with PyO3 and maturin
- Profiling before moving to Rust
- Project setup with maturin
#[pymodule],#[pyfunction], and#[pyclass]- Type conversions and the
BoundAPI - Rust errors as Python exceptions
- Detaching from the interpreter for CPU work
- Free-threaded Python and extensions
- NumPy arrays from Rust
- Type stubs for IDEs
- Wheels for Linux, macOS, and Windows
- Stable-ABI wheels with
abi3 - Testing with pytest
- Publishing to PyPI
AI-Assisted Rust Development for Python Engineers
- AI tools for Rust work
- Prompts for ownership and lifetimes
- Catching AI mistakes with the compiler
- Reviewing AI-generated
unsafeandunwrap - Reflexive
Arc<Mutex<T>>in AI code - AI-assisted refactors and code review