This repository provides a mapping from Rust tooling and language features to Python.
| Tool | Rust | Python |
|---|---|---|
| Package Repository | crates.io | PyPI |
| Multi-version Installation | rustup | uv python command |
| Package Management | Cargo | uv |
| Build Executables | Cargo | PyInstaller |
| Type Checking | Cargo | Mypy |
| Code Formatting | Rustfmt | Ruff Formatter, Ruff isort rules |
| Linting | Clippy | Ruff |
| Unit Testing | #[test] |
pytest |
| Scripts | cargo-script | uv run, Nox |
| Upgrade to New Language Features | cargo fix |
Ruff pyupgrade rules |
For a Python project example that incorporates these tools, see python-blueprint.
| Environment | Rust | Python |
|---|---|---|
| WASM | wasm-pack | PyScript, Pyodide, CPython WASM |
| Embedded | Embedded Rust | MicroPython, CircuitPython |
| Feature | Rust | Python |
|---|---|---|
| Interface | trait |
Protocol |
| Generics | <T> |
list[T] etc., def f[T], class C[T] |
| Pattern Matching | match |
match |
| Anonymous Function | |x| { x + 1 } |
lambda x: x + 1 |
| Foreign Function Interface | FFI | CFFI |
| Data Structure | Rust | Python |
|---|---|---|
| Data Type | struct |
@dataclass |
| Algebraic Data Type | enum |
Enum, Union of dataclass |
| Result | Result |
returns.Result |
| Optional | Option |
T | None, returns.Maybe |
| Fixed-sized Numerics | u8, u16, etc. |
NumPy Data Types |
- Both languages prefer
snake_casenaming overlowerCamelCase - Both languages use suffix type syntax (e.g.
x: int/x: i32) - Neither language is controlled by a single company