With PyO3 you mark Rust functions and structs with #[pyfunction], #[pyclass] and #[pymodule], and a build tool such as maturin turns the crate into an importable Python module. Argument conversion and error-to-exception mapping are generated for you.