Safe, fast Rust kernels exposed to Python via PyO3
Project description
rust_accel
rust_accel is a Rust-accelerated Python extension module built with PyO3 and maturin, designed to speed up computation-heavy numerical workloads while keeping a clean, Python-native API.
It is ideal for performance-critical paths in data processing, numerical optimization, and machine-learning pipelines where Python ergonomics and Rust speed are both required.
Features
- High-performance Rust kernels exposed to Python
- Seamless NumPy-compatible API
- Parallelized computation using Rayon
- Clean
python/source layout (no import shadowing) - Prebuilt wheels via maturin
- Memory-safe Rust implementation
Installation
From PyPI (recommended)
pip install rust-accel
From source (development)
git clone https://github.com/0rlych1kk4/rust_accel.git
cd rust_accel
python -m venv .venv
source .venv/bin/activate
pip install -U pip maturin
maturin develop
Usage
optimize_reconstruction
Computes a batched dot-product–style loss between an input matrix and multiple gradient matrices.
import numpy as np
import rust_accel
x = np.ones((2, 3), dtype=np.float32)
grads = np.stack([
np.full((2, 3), 2, np.float32),
np.full((2, 3), 3, np.float32),
], axis=0)
loss = rust_accel.optimize_reconstruction(x, grads)
print(loss) # 30.0
### clone_grad
Creates a Rust-side copy of a NumPy array and returns it as a flat Python list.
```python
import numpy as np
import rust_accel
x = np.ones((2, 3), dtype=np.float32)
flat = rust_accel.clone_grad(x)
print(len(flat)) # 6
print(flat[:3]) # [1.0, 1.0, 1.0]
Real-World Use Cases
- Accelerating inner loops in ML / optimization pipelines
- High-frequency numerical aggregation
- Scientific computing with Python frontends
- Hybrid Python–Rust systems where correctness and speed matter
- Safe native extensions without manual memory management
Contributing
We welcome contributions to the rust_accel project! If you'd like to contribute, please follow these steps:
- Fork this repository to your GitHub account.
- Clone your forked repository to your local machine:
git clone https://github.com/yourusername/rust_accel.git
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rust_accel-0.1.5-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: rust_accel-0.1.5-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 136.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d36fdc1673cfae099ada1beeeea98b6afaa1c2129fb9a48fb0f8df84864138bf
|
|
| MD5 |
732b268d3608198e67aef1957dc3d70c
|
|
| BLAKE2b-256 |
cacbf8222dfbed67134d3dc90b4aab7b67e99af82b210dd2ead3f10291a5eb5b
|
Provenance
The following attestation bundles were made for rust_accel-0.1.5-cp311-cp311-win_amd64.whl:
Publisher:
publish.yml on 0rlych1kk4/rust_accel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rust_accel-0.1.5-cp311-cp311-win_amd64.whl -
Subject digest:
d36fdc1673cfae099ada1beeeea98b6afaa1c2129fb9a48fb0f8df84864138bf - Sigstore transparency entry: 831771368
- Sigstore integration time:
-
Permalink:
0rlych1kk4/rust_accel@86f6a4b3b4eb36ba9ad4fc032085139ab20d50b8 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/0rlych1kk4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@86f6a4b3b4eb36ba9ad4fc032085139ab20d50b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rust_accel-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: rust_accel-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 262.6 kB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b49b8dc216268e7218a4a9296a99fecba79cdcfa75f259c01a5ddcd5f6ac67b
|
|
| MD5 |
ebd36a18621aa1a6c8a4817a2d9b2399
|
|
| BLAKE2b-256 |
e76a250c000c4a9f933e1f2e67fcd3c40ebf9209500f3e576ff966e9022c5b0c
|
Provenance
The following attestation bundles were made for rust_accel-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl:
Publisher:
publish.yml on 0rlych1kk4/rust_accel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rust_accel-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl -
Subject digest:
1b49b8dc216268e7218a4a9296a99fecba79cdcfa75f259c01a5ddcd5f6ac67b - Sigstore transparency entry: 831771371
- Sigstore integration time:
-
Permalink:
0rlych1kk4/rust_accel@86f6a4b3b4eb36ba9ad4fc032085139ab20d50b8 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/0rlych1kk4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@86f6a4b3b4eb36ba9ad4fc032085139ab20d50b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rust_accel-0.1.5-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: rust_accel-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 225.6 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
953226b6ffc039be0ecae3238ba04557f20ab4cf4776cb9c496e30c17e298f60
|
|
| MD5 |
29889aa70b65cfcdcdb54cfd8683ced8
|
|
| BLAKE2b-256 |
4bfea4dc88d2af09793371f2d4cc4600c13e281f6e64fe8c33da4a67b38370b6
|
Provenance
The following attestation bundles were made for rust_accel-0.1.5-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
publish.yml on 0rlych1kk4/rust_accel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rust_accel-0.1.5-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
953226b6ffc039be0ecae3238ba04557f20ab4cf4776cb9c496e30c17e298f60 - Sigstore transparency entry: 831771360
- Sigstore integration time:
-
Permalink:
0rlych1kk4/rust_accel@86f6a4b3b4eb36ba9ad4fc032085139ab20d50b8 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/0rlych1kk4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@86f6a4b3b4eb36ba9ad4fc032085139ab20d50b8 -
Trigger Event:
push
-
Statement type: