Skip to main content

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:

  1. Fork this repository to your GitHub account.
  2. Clone your forked repository to your local machine:
    git clone https://github.com/yourusername/rust_accel.git
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rust_accel-0.1.4-cp311-cp311-win_amd64.whl (136.2 kB view details)

Uploaded CPython 3.11Windows x86-64

rust_accel-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl (262.3 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

rust_accel-0.1.4-cp311-cp311-macosx_11_0_arm64.whl (226.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file rust_accel-0.1.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rust_accel-0.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 136.2 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

Hashes for rust_accel-0.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 167503ee246249b47ae0cabc262af8c2d7945773c3b92ee935e0fd3cb7ff2da1
MD5 37095ba0a4b723acfdba372bf510c0c7
BLAKE2b-256 9f1ea6c8c78586b4908d4352450a44c5e254ec5f623508d9ece5c503e6e8ebb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rust_accel-0.1.4-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on 0rlych1kk4/rust_accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rust_accel-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rust_accel-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9743d1446ffda294e4011c445d2a057563bb61627019ce8e32228706ccf48bf2
MD5 b2b529e977616dcef4a31c09736c2854
BLAKE2b-256 bea4213e42216c1172a9678474a54cbf06b607a6e39cb8aefea24fdab6d3c4ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for rust_accel-0.1.4-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on 0rlych1kk4/rust_accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rust_accel-0.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rust_accel-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee8e56c4283489d0002a7a9049c5c6b67c7c429d41de3fe86010985dc918c2e7
MD5 761388179c0eb8472b8878bab99e5046
BLAKE2b-256 22bd764401a4d02583d33a41f8f0515cc8e7116bdbd6756b6262c281196e3073

See more details on using hashes here.

Provenance

The following attestation bundles were made for rust_accel-0.1.4-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on 0rlych1kk4/rust_accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page