rust-numpy
Library Featured
PyO3-based Rust bindings of the NumPy C-API
- Downloads
- 3,598,884
- Dependents
- 388
- Stars
- 1,391
- Forks
- 140
- Contributors
- 65
- Commits
- 1,131
- Latest release
- 0.30.0 ·
About
Rust bindings for the NumPy C-API.
API documentation
Requirements
- Rust >= 1.85.0
- Basically, our MSRV follows the one of PyO3
- Python >= 3.9
- Python 3.7 support was dropped from 0.29
- Python 3.8 support was dropped from 0.30
- Some Rust libraries
- ndarray for Rust-side matrix library
- PyO3 for Python bindings
- And more (see Cargo.toml)
- numpy installed in your Python environments (e.g., via
pip install numpy)- We recommend
numpy >= 1.16.0, though older versions may work
- We recommend
Example
Write a Python module in Rust
Please see the simple example for how to get started.
There are also examples using ndarray-linalg and rayon.
[lib]
name = "rust_ext"
crate-type = ["cdylib"]
[dependencies]
pyo3 = { version = "0.30" }
numpy = "0.30"
Read the full README
#[pyo3::pymodule]
mod rust_ext {
use numpy::ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
use numpy::{IntoPyArray, PyArrayDyn, PyReadonlyArrayDyn, PyArrayMethods};
use pyo3::{pyfunction, PyResult, Python, Bound};
// example using immutable borrows producing a new array
fn axpy(a: f64, x: ArrayViewD<'_, f64>, y: ArrayViewD<'_, f64>) -> ArrayD<f64> {
a * &x + &y
}
// example using a mutable borrow to modify an array in-place
fn mult(a: f64, mut x: ArrayViewMutD<'_, f64>) {
x *= a;
}
// wrapper of `axpy`
#[pyfunction(name = "axpy")]
fn axpy_py<'py>(
py: Python<'py>,
a: f64,
x: PyReadonlyArrayDyn<'py, f64>,
y: PyReadonlyArrayDyn<'py, f64>,
) -> Bound<'py, PyArrayDyn<f64>> {
let x = x.as_array();
let y = y.as_array();
let z = axpy(a, x, y);
z.into_pyarray(py)
}
// wrapper of `mult`
#[pyfunction(name = "mult")]
fn mult_py<'py>(a: f64, x: &Bound<'py, PyArrayDyn<f64>>) {
let x = unsafe { x.as_array_mut() };
mult(a, x);
}
}
Execute a Python program from Rust and get results
[package]
name = "numpy-test"
[dependencies]
pyo3 = { version = "0.30", features = ["auto-initialize"] }
numpy = "0.30"
use numpy::{PyArray1, PyArrayMethods};
use pyo3::{types::{IntoPyDict, PyAnyMethods}, PyResult, Python};
fn main() -> PyResult<()> {
Python::attach(|py| {
let np = py.import("numpy")?;
let locals = [("np", np)].into_py_dict(py)?;
let pyarray = py
.eval(c"np.absolute(np.array([-1, -2, -3], dtype='int32'))", Some(&locals), None)?
.cast_into::<PyArray1<i32>>()?;
let readonly = pyarray.readonly();
let slice = readonly.as_slice()?;
assert_eq!(slice, &[1, 2, 3]);
Ok(())
})
}
Dependency on ndarray
This crate uses types from ndarray in its public API. ndarray is re-exported
in the crate root so that you do not need to specify it as a direct dependency.
Furthermore, this crate is compatible with multiple versions of ndarray and therefore depends
on a range of semver-incompatible versions, currently >= 0.15, <= 0.17. Cargo does not
automatically choose a single version of ndarray by itself if you depend directly or indirectly
on anything but that exact range. It can therefore be necessary to manually unify these dependencies.
For example, if you specify the following dependencies
numpy = "0.30"
ndarray = "0.15"
this will currently depend on both version 0.15.6 and 0.16.1 of ndarray by default
even though 0.15.6 is within the range >= 0.15, <= 0.17. To fix this, you can run
cargo update --package ndarray:0.16.1 --precise 0.15.6
to achieve a single dependency on version 0.15.6 of ndarray.
Contributing
We welcome issues and pull requests.
PyO3's Contributing.md is a nice guide for starting.
Also, we have a Gitter channel for communicating.
Compatibility
- Runs on
- GPU support unknown
What shows it
- no dependency or feature matches a backend row
- Native code
- None found
- No native code found
- Python bindings
- Has Python bindings
- numpy needs Python
- License
- BSD-2-Clause
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
PyO3-based Rust bindings of the NumPy C-API Python bindings |
3,598,884 downloads over 30 days | 388 | 1,391 | 0.30.0 | GPU support unknown | No native code found | BSD-2-Clause |
|
statrs Featured
Statistical computing library for Rust |
4,515,476 downloads over 30 days | 444 | 839 | 0.19.1 | GPU support unknown | No native code found | MIT |
|
rustfft Featured
High-performance FFT library written in pure Rust. |
4,266,035 downloads over 30 days | 571 | 963 | 6.4.1 | GPU support unknown | No native code found | Apache-2.0 OR MIT |
|
argmin Featured
Numerical optimization in pure Rust |
310,783 downloads over 30 days | 98 | 1,278 | 0.11.0 | GPU support unknown | Binds native code: lapack-sys (feature ndarray_v0_15) | Apache-2.0 OR MIT |
|
numr Listed
The base for numerical code in Rust, in the role NumPy has in Python: n-dimensional tensors, linear algebra, FFT, statistics and autograd on CPU, CUDA and WebGPU. The backends use native kernels, with no cuBLAS, MKL or other vendor math library. |
1,673 downloads over 30 days | 7 | 59 | 0.15.2 | CUDA, WebGPU | Binds native code: ring (feature distributed) | Apache-2.0 |
|
pounce New
Single-crate facade for POUNCE from Rust: re-exports the TNLP trait, the IpoptApplication driver, and the supporting types in one place (plus a prelude), with feature-gated modules for the convex/LP/QP, active-set QP, and sensitivity paths. |
2,486 downloads over 30 days | 9 | 81 | 0.16.0 | GPU support unknown | Binds native code: pounce-hsl (feature ma57) | EPL-2.0 |
Why FeaturedIt passes every Featured gate.
What it meets
- It has 180 active dependents and 137 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days.
- Active dependents are at 100% of their peak. Featured needs at least 50%.
- Docs are present. The release commit or a manifest ties the crate to the repository.
- No vulnerability advisory stays unpatched past the grace window. At least one version is neither a prerelease nor 0.0.x.
- The last activity is on 21 Oct 2026, 19 days ago. The rules expect an update within 560 days. Dormancy rule
Exact rules: Featured library. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: version 0.30.0 base 140, doubled for 3598884 downloads per month, doubled for 179.5 active users: E = 560 daysdormancy: last activity 2026-10-21, 19 days ago, E = 560: activefeatured: featured: active_users 179.5, new_adopters 137, former_glory 1
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources6 sources
- Description: the crates.io description
- crates.io database dump, fetched
- RustSec advisory database, fetched
- GitHub repository, fetched
- crates.io package, fetched
- GitHub contributors, fetched
Adoption180 active dependents, 137 new dependents in 365 days1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | 179.5 | crates.io database dump | Yes | |
| New dependents (365 days) | 137 | crates.io database dump | Yes | |
| Peak active dependents | 180 | crates.io database dump | Yes | |
| Active dependents as a share of the peak | 1 | crates.io database dump | Yes | |
| Binary downloads per release | Not measured | Yes |
MaintenanceLatest human commit: 19 days ago3 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2026-10-21 | GitHub repository | Yes | |
| Latest release | 2026-10-15 | crates.io database dump | Yes | |
| First release | 2017-05-10 | crates.io database dump | Yes | |
| Latest version | 0.30.0 | crates.io database dump | Yes | |
| Days the oldest outside issue waits for a reply | 809 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 52 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | true | crates.io package | Yes | |
| Published docs | true | crates.io database dump | Yes | |
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityUnpatched vulnerabilities: none
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | none | RustSec advisory database | Yes | |
| RustSec unmaintained advisory | none | RustSec advisory database | Yes | |
| Deprecation notice | none | crates.io database dump | Yes | |
| Deprecated requirement | none | crates.io database dump | Yes |
Distribution47 releases, 3,598,884 downloads over 30 days5 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | 47 | crates.io database dump | Yes | |
| Downloads over 30 days | 3598884 | crates.io database dump | Yes | |
| Binary downloads over the last 3 releases | Not measured | Yes | ||
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | false | crates.io database dump | Yes | |
| Every version 0.0.x | false | crates.io database dump | Yes | |
| Every version yanked | false | crates.io database dump | Yes | |
| Crate deleted from crates.io | false | crates.io database dump | Yes |
Repository1,391 stars, 140 forks, 65 contributors, 1,131 commits. Stars alone never qualify a project.
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 1391 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 140 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 65 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 1131 | GitHub repository | No | |
| Repository's main crate left out of the entry | none | crates.io database dump | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | BSD-2-Clause | crates.io database dump | No | |
| Runs on, from listed crates and their direct dependencies | GPU support unknown | crates.io database dump | No | |
| What shows each backend | no dependency or feature matches a backend row | crates.io database dump | No | |
| Native code, from listed crates and their dependencies | No native code found | crates.io database dump | No | |
| Python bindings, from direct dependencies of listed crates | Has Python bindings: numpy needs Python | crates.io database dump | No | |
| Crates that depend on a listed crate directly | 388 | crates.io database dump | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.