Outline updated November 2026
High-Performance Python with Rust
Class Duration
14 hours of live training delivered over 2-4 days to accommodate your scheduling needs.
Student Prerequisites
- Significant working experience in both Python and Rust
- Comfort with packaging, virtual environments, and the Rust toolchain
- This course is not a Rust introduction
Target Audience
Python and Rust developers building native Python extensions for performance, ML, data, or systems work. This includes teams that need a faster, GIL-free path for specific parts of a large Python codebase. New to Rust? Start with Rust for Python Programmers. Teams that prefer C or C++ as the native layer can take High-Performance Python with C, C++, and Cython instead.
Description
This advanced course is for engineers who know Python and Rust and want to ship a native Python extension. It starts with profiling to find the right hot path, then builds extensions with PyO3 and Maturin. Students expose functions and classes, convert types, release the GIL, and support free-threaded Python. They also use threads and async/await across the boundary and package wheels for PyPI, including stable ABI wheels. AI assistants help with boilerplate and type conversions, and students learn where to check their ownership and GIL handling.
Learning Outcomes
- Profile Python applications to find hot paths worth rewriting in Rust
- Build Rust extensions with PyO3 and Maturin
- Expose Rust modules, classes, functions, and exceptions to Python
- Convert types across the Python and Rust boundary
- Release the GIL for CPU-bound Rust work
- Support free-threaded Python in PyO3 extensions
- Use threads, parallelism, and async/await across the boundary
- Package and publish wheels to PyPI from a CI build matrix
- Use AI coding assistants for PyO3 work and review their GIL handling
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, current stable Rust installed via rustup (2024 edition), Python (including the free-threaded build), Visual Studio Code or another supported editor with the rust-analyzer extension, Maturin, and an AI coding assistant of choice (GitHub Copilot, Cursor, or Claude Code). The course is taught on Python 3.15 and PyO3 0.30. A cloud-based environment can be provided if local installation is restricted.
Training Topics
Why Rust Inside Python
- The shape of Python performance problems
- CPU-bound vs. IO-bound work
- Where PyO3 wins
- When to stay in Python
- The cost of native extensions
Profiling and Measurement
- The Tachyon sampling profiler
py-spy,scalene, andcProfile- Reference counting and memory leaks
- Debug Python builds
- Valgrind
- Benchmarks with
pytest-benchmarkandcriterion
Debugging Across the Boundary
- Compiling Rust extensions with debug symbols
- Debugging Rust + Python in VS Code
- Symbol management on Linux, macOS, and Windows
- Reproducing crashes in CI
PyO3 and Maturin Workflow
- The
BoundAPI - Recent PyO3 API changes
- Project layout with Maturin
#[pymodule]and#[pyfunction]#[pyclass]and#[pymethods]- Building, installing, and reloading during development
- Publishing wheels with
maturin publish
Python and Rust Integration
- Modules and submodules
- Declarative modules
- Functions, signatures, and default arguments
- Type conversions
Bound<'py, PyAny>,Py<T>, andPyResult- Exposing Rust classes to Python with
#[pyclass] - Mapping Rust errors to Python exceptions
- Calling Python functions from Rust
The GIL and Parallelism
- What the GIL costs
- Releasing the GIL with
Python::detach - Threading and
Send/Syncboundaries - Parallelism with
rayoninside Rust extensions - Async/await with
pyo3-async-runtimes - Declaring free-thread safety
- Shared state in
#[pyclass]types - Measuring GIL-free speedups
Distributing Rust Extensions
- Release builds and optimization profiles
- Cross-platform wheels with
maturin - Building manylinux wheels with
cibuildwheel - Publishing to PyPI and an internal index
- abi3 and abi3t stable ABI wheels
- Version-specific and free-threaded wheels
AI-Assisted PyO3 Workflow
- Where AI assistants help with PyO3
- GIL and ownership mistakes in AI output
- Prompts for type conversions and error mapping
- The compiler, clippy, and tests as the check
- Reviewing AI-generated
unsafe,unwrap, andPython::detachblocks - AI-assisted refactoring of a Python hot path