A high-performance N-dimensional array library built in Rust for macOS.
Project description
🚀 Zanpy
Zanpy is a high-performance N-dimensional array library built in Rust with a seamless Python interface. It leverages SIMD (Single Instruction, Multiple Data) and cache-efficient memory layouts to provide blazing-fast linear algebra operations.
✨ Features
- Native Rust Engine: Memory-safe, high-speed core implementation.
- SIMD Acceleration: Matrix multiplication optimized with
wideSIMD types (f64x2) and $i, k, j$ loop reordering. - N-Dimensional Support: Sophisticated broadcasting for arrays up to 8 dimensions.
- Numpy-Compatible: Familiar Python syntax for
reshape,transpose,arange, andidentity. - Linear Algebra: Built-in LU decomposition for matrix inversion and dot product support.
📦 Installation
To install the latest release via pip:
pip install zanpy
Note: For local development, see the Development section.
🛠 Usage
Basic Array Creation
import zanpy
# Create a 2x2 identity matrix
identity = zanpy.PyNdArray.identity(2)
# Create an array from a range and reshape it
a = zanpy.PyNdArray.arange(0, 4, 1).reshape([2, 2])
Arithmetic & Broadcasting
b = zanpy.PyNdArray.ones([2, 2])
# Element-wise addition using the + operator
c = a + b
# Matrix Multiplication using the @ operator
d = a @ identity
Reductions & Math
print(f"Matrix Sum: {a.sum()}")
print(f"Matrix Mean: {a.mean()}")
print(f"Matrix Max: {a.max()}")
# Invert a square matrix
a_inv = a.inv()
🏗 Architecture
Zanpy is architected for speed by separating the math logic from the Python glue:
zanpy-core: The standalone Rust crate. It manages theNdArraystruct, calculating memory offsets via strides and executing raw SIMD math.zanpy-py: The bridge crate. Uses PyO3 and Maturin to expose Rust functionality as a Python module.
Why it's fast
The mat_mul implementation avoids the "cache-miss" penalty of naive triple-nested loops by using an $i, k, j$ traversal. This ensures that the CPU accesses memory in a linear, predictable fashion, maximizing cache hits.
🛠 Development
Prerequisites
- Rust (1.70+ recommended)
- Python (3.9+)
- Maturin (
pip install maturin)
Building from Source
# Clone the repository
git clone [https://github.com/yourusername/zanpy.git](https://github.com/yourusername/zanpy.git)
cd zanpy
# Compile and install in your current virtual environment
cd crates/zanpy-py
maturin develop --release
Testing
# Run Rust unit tests
cargo test
# Run Python integration tests
pytest tests/
📜 License
Distributed under the MIT License. See LICENSE for more information.
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 Distribution
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 zanpy-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: zanpy-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 214.8 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
147ba8d6ed77b69ecf91addc5542a3c40c6d8707be1dea901cd328f30061d451
|
|
| MD5 |
a665e6c7b671a91d9aae4fe31e10ad8d
|
|
| BLAKE2b-256 |
010e944863c9ca22e6c4ca1f6690885f14fb70af8f9dc10dd3ca3b436af85dba
|
Provenance
The following attestation bundles were made for zanpy-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on Mersautschip/zanpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zanpy-0.1.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
147ba8d6ed77b69ecf91addc5542a3c40c6d8707be1dea901cd328f30061d451 - Sigstore transparency entry: 1298234433
- Sigstore integration time:
-
Permalink:
Mersautschip/zanpy@91180e6e0d99636419760ff9ea880d0414fa8899 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/Mersautschip
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@91180e6e0d99636419760ff9ea880d0414fa8899 -
Trigger Event:
push
-
Statement type: