Outline updated November 2026

Advanced14 hours delivered over 2-4 daysLive, online or on-site

Request this course

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, and cProfile
  • Reference counting and memory leaks
  • Debug Python builds
  • Valgrind
  • Benchmarks with pytest-benchmark and criterion

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 Bound API
  • 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>, and PyResult
  • 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/Sync boundaries
  • Parallelism with rayon inside 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, and Python::detach blocks
  • AI-assisted refactoring of a Python hot path

Private team training

Bring this course to your team

Tell us about your team and we will tailor this outline to your tools, stack, and schedule. Courses can also be combined into a longer program.

  1. Tell us what you needYour tools, stack, team size, and timeline.
  2. We send a proposalA course or program, an outline adjusted to your team, and possible dates.
  3. Your team trains liveOnline or on-site, with courseware for every student.

Prefer to talk? Call +1 434-509-6890 or email help@cloudcontraptions.com.

We reply within 1 business day.

Training partner?