PyO3/rust-numpy

PyO3-based Rust bindings of the NumPy C-API

What it solves

rust-numpy provides Rust bindings for the NumPy C-API, allowing developers to write high-performance Rust code that can be seamlessly integrated into Python environments. It bridges the gap between Python's NumPy arrays and Rust's ndarray library, enabling efficient data exchange and manipulation of numerical data without the overhead of copying data between the two languages.

How it works

The library leverages PyO3 to create Python bindings. It allows Rust functions to accept NumPy arrays as arguments (via PyReadonlyArray or PyArray types) and return NumPy arrays back to Python. It integrates deeply with the ndarray crate, re-exporting its types to ensure compatibility between Rust-side matrix operations and Python-side array manipulation.

Who it’s for

Developers who need to write performance-critical numerical computing tasks in Rust while maintaining a Python interface for the end-user, or those who want to execute Python programs from within Rust and handle NumPy arrays as native Rust types.

Highlights

  • NumPy C-API Bindings: Direct access to NumPy's core functionality from Rust.
  • ndarray Integration: Seamlessly converts between NumPy arrays and Rust's ndarray types.
  • C-API Efficiency: Enables in-place modification of arrays and immutable borrows for high-performance computing.
  • PyO3 Ecosystem: Built on top of PyO3 for robust Python-Rust interoperability.

Related

  • Project
  • Project
  • Project
  • Project
  • Project