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.5-cp311-cp311-win_amd64.whl (136.1 kB view details)

Uploaded CPython 3.11Windows x86-64

rust_accel-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl (262.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

rust_accel-0.1.5-cp311-cp311-macosx_11_0_arm64.whl (225.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Hashes for rust_accel-0.1.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d36fdc1673cfae099ada1beeeea98b6afaa1c2129fb9a48fb0f8df84864138bf
MD5 732b268d3608198e67aef1957dc3d70c
BLAKE2b-256 cacbf8222dfbed67134d3dc90b4aab7b67e99af82b210dd2ead3f10291a5eb5b

See more details on using hashes here.

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

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.5-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rust_accel-0.1.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 1b49b8dc216268e7218a4a9296a99fecba79cdcfa75f259c01a5ddcd5f6ac67b
MD5 ebd36a18621aa1a6c8a4817a2d9b2399
BLAKE2b-256 e76a250c000c4a9f933e1f2e67fcd3c40ebf9209500f3e576ff966e9022c5b0c

See more details on using hashes here.

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

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.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rust_accel-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 953226b6ffc039be0ecae3238ba04557f20ab4cf4776cb9c496e30c17e298f60
MD5 29889aa70b65cfcdcdb54cfd8683ced8
BLAKE2b-256 4bfea4dc88d2af09793371f2d4cc4600c13e281f6e64fe8c33da4a67b38370b6

See more details on using hashes here.

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

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