PyO3

pyo3: Connect Rust Code with Python

PyO3 lets Rust code work with Python in both directions: build native Python extension modules or embed Python in Rust programs. It suits developers who want Rust functionality in Python packages or Python libraries available to Rust applications.

ActiveRustApache-2.0PythonLibraryDeveloper Tools
View on GitHub Compare
Stars
16.2k
Forks
1k
Stars, last 30 days
+98
Last commit
today
Contributors
100+

Our take

Activeregular commits and releases

Health score

70/100

How it is scored
Activity
75
Community
86
Issues
55
Pull requests
63

+98 stars in the last 30 days

  • Merges more pull requests than 91% of the projects we track
  • More contributors than 78% of the projects we track

PyO3 is a mature, actively maintained foundation for Rust-Python interoperability, with recent releases and contributions from a broad contributor base.

Good fit if

  • You need to build a Python extension in Rust or embed Python in a Rust application.
  • Your project can use Rust 1.85 or newer and one of the supported Python distributions.
  • You want an established project with regular commits and releases, and a contributor base that is not concentrated in one person.

Look elsewhere if

  • You need a binding layer for a language other than Rust and Python.
  • Your environment cannot meet the stated Rust or Python version requirements.
  • You need a library that does not involve Python's interpreter or Python extension modules.
All health signals
Last commit2026-10-06 (today)
Commits, last 90 days100+
Releases, last 12 months11 (latest v0.29.3, 2026-09-30)
Contributors100+ (top contributor: 35% of commits)
Issues closed, last 90 days8+ (typically closed in 6 days)
Project age9 years

Checked on 2026-10-07 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

16,328

Forks

1,054

Change since Nov 14, 2026: +4 stars·+2 forks

Overview

PyO3 provides Rust bindings to the Python interpreter and its C API. It handles the language boundary so Rust developers can expose functions and types to Python, or call Python code from a Rust program.

Use it when you want to implement part of a Python package in Rust, or incorporate Python libraries into a Rust application. The project includes a user guide and API documentation, with maturin as a recommended way to build and install extension modules.

Key Features

  • Build native Python extension modules using Rust functions and types.
  • Embed a Python interpreter in a Rust binary and call Python code.
  • Convert values between Rust and Python through its binding APIs.
  • Support CPython 3.9 and newer, PyPy 7.3 for Python 3.11+, and GraalPy 25.0 for Python 3.12+.
  • Integrate with maturin, setuptools-rust, or manual build workflows.
  • Provide a user guide, API documentation, examples, and an architecture guide.

Use Cases

  • Python package maintainers can implement computationally intensive or systems-oriented components in Rust while keeping a Python-facing interface.
  • Rust application developers can embed Python to reuse Python code or libraries from a Rust program.
  • Teams building data and scientific Python tools can expose Rust libraries through a native extension module.
  • Rust library authors can offer Python bindings so Python users can access Rust functionality.

What you need

Detected in the repository

  • Python >=3.9 (from pyproject.toml)
  • Rust 1.85 or newer (from Cargo.toml)
  • A test suite and automated checks on GitHub Actions

License in plain words

Apache-2.0permissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the license, the NOTICE file and a note of your changes
  • Share your changes: no
  • Includes an explicit patent grant from the contributors:

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

For a Python extension, install maturin, initialize a project with PyO3 bindings, then build and install it in your active Python environment:

pip install maturin
maturin init --bindings pyo3
maturin develop

See the README and user guide for setup details and embedding examples.

Considerations

  • Building and distributing native extensions involves Rust and Python toolchains; embedded Python also requires a Python installation with a shared library.
  • The documented minimums are Rust 1.85 and CPython 3.9, with more limited version ranges for PyPy and GraalPy. Check compatibility with your deployment environment.
  • The repository uses an Apache-2.0 or MIT license, at your option. Review the applicable terms for your distribution and contribution workflow.
  • PyO3 supplies the bindings, not a complete Python package build-and-publish workflow. The README points to tools such as maturin and setuptools-rust for those tasks.

Found this useful?

Share it with someone who would like pyo3.

Comparisons