Belderbos iconBelderbosSep 13, 2026 ~1 min source read

Bob Belderbos: How Libraries Run Rust Inside Python (with PyO3)

Every time you validate data with Pydantic v2, the data-validation library most Python apps reach for, a Rust extension does the work. Its core, pydantic-core, is built with PyO3, the same toolchain we'll use here.

Bob Belderbos: How Libraries Run Rust Inside Python (with PyO3)

Share this story

Send the public story page.

Useful takeaways from this story.

Every time you validate data with Pydantic v2, the data-validation library most Python apps reach for, a Rust extension does the work.

Its core, pydantic-core, is built with PyO3, the same toolchain we'll use here.

The last step, turning the Rust result into Python objects, is the one to understand before you port anything: for a parser like this, it can cost more than the parsing itself.

Building the complete brief

The page is ready to read now. The fuller skim-friendly version will appear here automatically.

The useful part

Every time you validate data with Pydantic v2, the data-validation library most Python apps reach for, a Rust extension does the work. Its core, pydantic-core, is built with PyO3, the same toolchain we'll use here. The last step, turning the Rust result into Python objects, is the one to understand before you port anything: for a parser like this, it can cost more than the parsing itself.

How it works

Details worth keeping

#[pyfunction] and #[pymodule] are the two Rust macros that do the wiring.

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app