Rust-powered random generation for Python Blazing-fast RNG utilities with parallel computation and distribution support. β‘ππ¨
- π² Generate random integers, floats, and arrays
- π Shuffle lists or sample subsets
- β‘ Parallelized operations with Rayon
- π§© Multiple distributions: uniform, normal, etc.
- π§ Fully compatible with Python 3.13+ and PyO3 forward-compatibility
- βΉοΈ Is fully typed.
# From dist/ folder
python -m pip install dist\pyrand-x.x.x-cp3xx-cp3xx-win_amd64.whl --force-reinstallOr build from source:
.\build.ps1import pyrand
# Seed RNG
pyrand.set_seed(42)
# Single random number
x = pyrand.randfloat()
print("Random float:", x)
# Random integer
y = pyrand.randint(1, 100)
print("Random int:", y)
# Random array
arr = pyrand.rand_array(5, 1.0, 10.0)
print("Random array:", arr)
# Shuffle list
lst = [1, 2, 3, 4, 5]
pyrand.shuffle(lst)
print("Shuffled:", lst)| Function | Description |
|---|---|
set_seed(seed) |
Set RNG seed for reproducibility |
randfloat() |
Random float [0, 1) |
randint(a, b) |
Random integer between a and b |
rand_array(n, low, high) |
Generate array of n random floats |
uniform(low, high) |
Single uniform random float |
choice(seq) |
Pick a random element |
sample(seq, k) |
Random sample of k elements |
shuffle(seq) |
Shuffle in-place |
- Python 3.10+
- Rust toolchain
- Maturin
- PyO3
.\build.ps1- Wheel gets copied to
dist/ - Installed automatically to your current Python
- Parallel random generation is backed by Rayon
- Designed to replace slow Python loops in heavy random computations
MIT Β© Soumalya Das