Skip to main content

RustyLab

Numerical Accuracy Testing PyPI version License: MIT

🚧 RustyLab is under active development and its functionality is subject to change.

RustyLab is a high-performance scientific computing and machine learning library for Python, with its numerical core written entirely in Rust.

It aims to unify the core functionality of SciPy, statsmodels, and scikit-learn into a single, cohesive Python library with a strong focus on speed, safety, and ergonomics.

RustyLab is built in Rust and exposed to Python using PyO3 and maturin, with a thin Python layer that offers the same routines as native Polars expressions - combining Rust's performance with Python's ease of use.


🚀 Why RustyLab?

The Python scientific ecosystem is powerful, but fragmented:

  • Numerical routines live in SciPy;
  • Statistical modelling in statsmodels;
  • Machine learning in scikit-learn;
  • Performance is built on a long-evolving foundation of native implementations and Python APIs.

RustyLab takes a different approach:

  • Rust numerical core - memory safe, fast, and modern (i.e., the Python layer only builds expressions);
  • Polars-native data model - designed for full compatibility with Polars;
  • Unified API - statistics, optimization, and ML under one roof;
  • Python bindings - no compromises in usability;
  • Performance by default - zero-cost abstractions and parallelism;
  • Safe & predictable - fewer runtime surprises.
  • Auditable source - all function implementations are readily accessible, with Wiki references pointing to the exact code locations.

📦 Quickstart

Install the latest release of RustyLab Python client using pip:

pip install rustylab

Once installed, you can import the RustyLab library, any of its modules, or individual functions:

>>> import rustylab                     # Import the full library
>>> rustylab.special.beta(0.5, 0.5)

>>> from rustylab import special        # Import a specific module
>>> special.beta(0.5, 0.5)

>>> from rustylab.special import beta   # Import a function directly
>>> beta(0.5, 0.5)

>>> import polars as pl                 # Use the same routines as Polars expressions
>>> from rustylab import expr
>>> pl.DataFrame({"x": [0.0, 1.0, 2.0]}).with_columns(
...     pdf = expr.stats.norm.pdf("x")
... )

📏 Numerical Accuracy

RustyLab is designed to deliver highly accurate and reproducible numerical results. In practice, this means that values produced by RustyLab agree with trusted reference implementations to approximately 13–15 significant decimal digits (≈ 99.999999999999% accuracy, where relative error is meaningful, or with a difference smaller or equal to 1e-15). This level of precision is consistent with the practical limits of double‑precision (f64) floating‑point arithmetic.

RustyLab functions are systematically benchmarked against a trusted Python alternative, such as mpmath, NumPy, SciPy, or equivalent reference implementations. This ensures that:

  • Numerical results closely match established Python scientific computing standards.
  • Edge cases, including near‑zero values, very large magnitudes, and numerically sensitive operations, are handled consistently.
  • Any deviations from reference implementations are intentional, well‑understood, and documented.

To validate this level of accuracy:

  • Outputs are tested via tolerance‑based comparisons using pytest.approx.
  • The tolerance‑based checks make use of the following strict thresholds:
    • Relative tolerance: 1e-12
    • Absolute tolerance: 1e-15

The tolerance‑based checks make use of both relative and absolute tolerances simultaneously, following the semantics of pytest.approx: a comparison passes if either the relative error or the absolute error is within the specified bounds. In practice, this means that values with a meaningful scale are validated to many significant digits via the relative tolerance, while near‑zero or scale‑free quantities are validated via a strict absolute error bound. In all cases, the tolerances are chosen to reflect the limits of double‑precision floating‑point arithmetic and to ensure numerically correct results.

By combining high‑precision testing, strict absolute and relative error bounds, and direct comparison against well‑known Python libraries, RustyLab provides transparent and verifiable numerical accuracy suitable for both general‑purpose computation and demanding scientific workloads.

📚 Documentation & Module Reference

RustyLab’s full API documentation is maintained in the project's Wiki, which includes:

  • A structured overview of all available modules.
  • Documentation strings for every public function.
  • Direct links to the corresponding Rust source files.
  • Usage examples.

Explore the documentation here:
👉 RustyLab Wikihttps://codeberg.org/esuriddick/rustylab/wiki

The Wiki is continuously updated as new features are added, making it the best place to understand the library’s capabilities.

Download files

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

Source Distribution

rustylab-0.3.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

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

rustylab-0.3.0-cp310-abi3-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

rustylab-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

rustylab-0.3.0-cp310-abi3-macosx_11_0_arm64.whl (4.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file rustylab-0.3.0.tar.gz.

File metadata

  • Download URL: rustylab-0.3.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rustylab-0.3.0.tar.gz
Algorithm Hash digest
SHA256 45a33eb05222e14e71c007f4afc0b6a6749011a0aa82073cc860ebebd7109173
MD5 9e6d49960eae54e9449d6d53ee809d8d
BLAKE2b-256 aa6cdf0def96e88482d26460c8794dd87ad136309f98bad03d6c1d043e6529a6

See more details on using hashes here.

File details

Details for the file rustylab-0.3.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rustylab-0.3.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rustylab-0.3.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e0d498c15508e3226cc5878ec7aebef137ebc6dbf4e130235af4be32707a4a41
MD5 992a53de821d5048d582b17015236bb7
BLAKE2b-256 0190297a85518b73e33a6f9b89a88ec6559fa62c84b4438ccbeab15ac9a2b8b0

See more details on using hashes here.

File details

Details for the file rustylab-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: rustylab-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 5.3 MB
  • Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rustylab-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 78a798870c382c3bc8570d020b6322668ca597a7d8fd270c7c4e6fe9208f339d
MD5 a1afae723f021f2722d2b8590b1c6544
BLAKE2b-256 1dceaaa87050a86060f76e951e2a0756ac56b132ac4a2e23673e068226c3f3de

See more details on using hashes here.

File details

Details for the file rustylab-0.3.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: rustylab-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 4.7 MB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rustylab-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80a1d64c05b62a25c28b96e9a93361d4bf91e409bcf187e6fdfaa6d1d28a7579
MD5 fa36fa8b4d7307d48a06843e12ccbcb6
BLAKE2b-256 55dc7479c93f0223dbb16d0cf1e7cc31f12238566a6be28c20ba2a1ae90d918f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

4 files

0.2.0

3 files

0.1.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page