Background

PyO3 and Logferry

1 min read

This chapter covers the PyO3 bridge between Rust and Python, using logferry as the concrete working example throughout.

Articles

Article Topics covered
PyO3 Overview What PyO3 is, project setup, type mapping table
Exposing Functions #[pyfunction], signatures, default arguments
Exposing Classes #[pyclass], #[pymethods], getters, __repr__
Error Handling in PyO3 PyResult, From<MyError>, Python exception types
Multithreading and the GIL py.allow_threads, thread::scope, Send + Sync
logferry Walkthrough End-to-end walk through src/lib.rs
Distribution maturin build, wheels, type stubs, mixed layouts

Prerequisites

Chapter 2 — Rust Language Fundamentals, especially Error Handling and Traits and Generics.

Next

Chapter 5 — Reference for quick-lookup tables and troubleshooting.