| Crates.io | radix256_sort |
| lib.rs | radix256_sort |
| version | 0.1.0 |
| created_at | 2025-12-04 02:09:33.77582+00 |
| updated_at | 2025-12-04 02:09:33.77582+00 |
| description | A high-performance Radix Sort implementation using base-256 for u32. |
| homepage | https://github.com/tanep3/radix256Sort |
| repository | https://github.com/tanep3/radix256Sort |
| max_upload_size | |
| id | 1965707 |
| size | 29,257 |
日本語 (Japanese) | Technical Details
A high-performance, stable Radix Sort implementation for u32 integers, written in Rust with Python bindings.
Optimized for CPU cache efficiency and zero-allocation (internal loop) strategy.
std::slice::sort) and Python's list.sort / numpy.sort for large datasets.unsafe blocks.git clone https://github.com/tanep3/radix256Sort.git
cd radix256Sort
Run unit tests:
cargo test --workspace
Run micro-benchmarks (Criterion):
cargo bench -p radix256_sort
Results will be generated at target/criterion/report/index.html.
Run macro-benchmarks (100M items):
cargo run --release -p rust_bench
It is recommended to use a virtual environment.
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install build tools
pip install maturin numpy
# Build and install the library
cd radix256_sort_py
maturin develop --release
cd ..
# Run benchmarks
python benchmarks/python_bench/bench.py
use radix256_sort::radix256_sort_vec;
let mut data = vec![5, 2, 9, 1, 5];
let sorted = radix256_sort_vec(data);
assert_eq!(sorted, vec![1, 2, 5, 5, 9]);
Or in-place:
use radix256_sort::radix256_sort_inplace;
let mut data = vec![5, 2, 9, 1, 5];
radix256_sort_inplace(&mut data);
assert_eq!(data, vec![1, 2, 5, 5, 9]);
import radix256_sort_py
data = [5, 2, 9, 1, 5]
sorted_data = radix256_sort_py.radix256_sort(data)
print(sorted_data) # [1, 2, 5, 5, 9]
Performance measured on 100,000,000 (100M) random u32 integers.
[!NOTE] The following figures are reference values from a development environment. Performance may vary depending on the system.
radix256_sort_vec: This library (Buffer version) - Fastestradix256_sort_inplace: This library (In-place version)std_sort: Rust standard stable sort (Comparison target)std_sort_unstable: Rust standard unstable sort (Reference)| Algorithm | Time (s) | Speedup |
|---|---|---|
std::slice::sort |
2.99s | 1.0x |
radix256_sort_vec |
0.84s | 3.56x |
| Algorithm | Time (s) | Speedup (vs list) |
|---|---|---|
list.sort() |
76.89s | 1.0x |
radix256_sort |
7.61s | 10.1x |
numpy.sort() |
5.27s | 14.6x |
The benchmark results demonstrate that radix256_sort significantly outperforms standard library implementations in both Rust and Python for large datasets.
std::slice::sort (pdqsort) confirms the efficiency of the cache-friendly, fixed-pass approach compared to generic comparison-based sorts.list.sort makes it a powerful alternative for heavy number crunching in pure Python environments. While numpy.sort is faster (5.27s), it requires the NumPy dependency. radix256_sort provides near-NumPy performance (7.61s) for standard lists, with the overhead largely due to the O(N) cost of converting Python lists to Rust vectors.For detailed technical explanation of why this is so fast, see Technical Details.
Apache License 2.0
Copyright (c) 2025 Tane Channel Technology