Skip to main content

fast-math-rs

PyPI Python CI License

Arithmetic and number theory on Python numbers, implemented in Rust.

Every function behaves as the Python operator or math function of the same name: int with int gives an exact int, anything with a float gives a float, -7 // 2 is -4, and the errors are Python's own. The one difference is the width of an integer: 64 bits, and a result that does not fit raises OverflowError instead of growing. The core is written in Rust with PyO3, ships as one wheel per platform for every CPython from 3.11 on, and runs without the GIL on free-threaded Python.

Installation

pip install fast-math-rs

The distribution is fast-math-rs (PyPI keeps fast-math for the older fastmath); the module it installs is fast_math.

Requires CPython 3.11+. Wheels: Linux (x86_64, aarch64; glibc and musl), macOS (x86_64, arm64) and Windows (x64), each an abi3 wheel plus one for free-threaded CPython 3.14t. Elsewhere pip builds the sdist, which needs a Rust toolchain.

Quick start

>>> import fast_math as fm
>>> fm.add(2, 3)
5
>>> fm.add(2, 0.5)
2.5
>>> fm.div(7, 2)
3.5
>>> fm.floordiv(-7, 2), fm.mod(-7, 2)
(-4, 1)
>>> fm.pow(2, 10), fm.pow(2, -1)
(1024, 0.5)
>>> fm.gcd(12, 18), fm.lcm(4, 6)
(6, 12)
>>> fm.is_prime(2**61 - 1)
True
>>> fm.primes_up_to(30)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

An integer result beyond 64 bits raises instead of wrapping around or losing precision:

>>> fm.add(2**63 - 1, 1)
Traceback (most recent call last):
  ...
OverflowError: integer result does not fit into 64 bits
>>> fm.factorial(21)
Traceback (most recent call last):
  ...
OverflowError: integer result does not fit into 64 bits

Functions

function Python equivalent result
add(a, b), sub(a, b), mul(a, b) a + b, a - b, a * b int for two ints, float otherwise
div(a, b) a / b always float, correctly rounded for two ints
floordiv(a, b), mod(a, b) a // b, a % b floored: the remainder has the sign of b
pow(base, exp) base ** exp int for an int base and a non-negative int exponent
abs(x) abs(x) the type of x
sqrt(x) math.sqrt(x) float
gcd(a, b), lcm(a, b) math.gcd(a, b), math.lcm(a, b) int, never negative
factorial(n) math.factorial(n) int, up to factorial(20)
fibonacci(n) — int, fibonacci(0) == 0, up to fibonacci(92)
is_prime(n) — bool, exact for every 64-bit integer
primes_up_to(n) — list[int] of the primes <= n, without the GIL meanwhile

Arguments are int (and bool) or float; anything else raises TypeError, an int beyond 64 bits OverflowError. Every difference from Python is listed in Semantics.

Performance

A call into Rust costs about 20 ns more than a call of a C builtin, so fast_math.add is slower than a + b; the core pays off where it does the work in a loop. On an Apple M-series CPU, Python 3.14:

operation fast_math baseline speedup
add(2, 3) 48 ns operator.add, 26 ns 0.54x
fibonacci(90) 66 ns Python loop, 1.6 µs 24x
is_prime, 1000 numbers near 10**18 0.90 ms Python Miller-Rabin, 4.9 ms 5.5x
primes_up_to(10**6) 2.2 ms Python sieve, 19.8 ms 9.0x

Every case and how to rerun them: Benchmarks.

Documentation

License

MIT

Metadata

Release files for fast-math-rs 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-math-rs 0.1.1
File Size Uploaded Provenance
fast_math_rs-0.1.1.tar.gz 81.1 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for fast-math-rs 0.1.1
File
fast_math_rs-0.1.1-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details
fast_math_rs-0.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 Details
fast_math_rs-0.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64 Details
fast_math_rs-0.1.1-cp314-cp314t-manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64 Details
fast_math_rs-0.1.1-cp314-cp314t-manylinux_2_28_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64 Details
fast_math_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details
fast_math_rs-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 Details
fast_math_rs-0.1.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
fast_math_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl CPython 3.11 abi3 Linux musl 1.2+ x86-64 Details
fast_math_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl CPython 3.11 abi3 Linux musl 1.2+ ARM64 Details
fast_math_rs-0.1.1-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
fast_math_rs-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
fast_math_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
fast_math_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 3.3 MB

Release files / fast_math_rs-0.1.1.tar.gz

Download URL fast_math_rs-0.1.1.tar.gz
Size 81.1 kB
Tags Source
SHA-256 checksum
How to use checksums
35bddcfd27be6e1c370912d1a7bbc33bde07e635be7c189cf33857644e8ae8fb
BLAKE2b-256 checksum
How to use checksums
c989f29f90fd85b8b1086e0d60c29907ef94232b2286819412690815716d5bfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-win_amd64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-win_amd64.whl
Size 105.1 kB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
4a1cc668981b8d4194c0f1d7592e1a5ed18840afbfa94fb16d23611fab9332ac
BLAKE2b-256 checksum
How to use checksums
71ccf077dcd52b022cf7d5629ed6a432295709ac7d2bf46cf02fa9b8700ffe18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Size 403.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
d36106e498be6f9663557dc7fc58c486833687ea3d9d752e28f152a67a844afa
BLAKE2b-256 checksum
How to use checksums
eca94b4d3e29124b227aea51fdedb7892c818f6f7a799b5899af082b3d33009a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl
Size 364.7 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64
SHA-256 checksum
How to use checksums
efa25462a313d73353c68602ffa97a32e1bf8a98371d02ac3e83bc682bab49ff
BLAKE2b-256 checksum
How to use checksums
071f503b2082270a1664a5dc53d096bb8b74f0bb16bad89b7e95aa6de09e981a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-manylinux_2_28_x86_64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-manylinux_2_28_x86_64.whl
Size 191.4 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
49aa100cbb464b233393a1dc4b69e77b0a80110d1ba178bc9509260194aa6254
BLAKE2b-256 checksum
How to use checksums
17129f7cf04bb053039166482f920a8e2db723972f3ea0a22aab80db77525215
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-manylinux_2_28_aarch64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-manylinux_2_28_aarch64.whl
Size 186.7 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
12f2d8e77799ba42928de4e495f3c1721894ed18c66a52f572ce023e798e21bd
BLAKE2b-256 checksum
How to use checksums
edd782f6e50d35c41bf45d74cc42dcdb5ae707c4c15eb2b3c0d7670fe5b53d3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-macosx_11_0_arm64.whl
Size 178.8 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ced3a50e9c1877d6d31295cf86b54689d8dc94d62626c0bb25414f54fd5baf90
BLAKE2b-256 checksum
How to use checksums
819afe403b6ac4e3805e27582204b927a287d7f05b05e9a8342ee62537befc58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL fast_math_rs-0.1.1-cp314-cp314t-macosx_10_12_x86_64.whl
Size 187.4 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ba30774c531478bd7db13f3a02bea2c0534148f409604848a9bccd9451a3ab33
BLAKE2b-256 checksum
How to use checksums
9942ac9d54a2c45beb79ccea77ad1e07528347069de02f1584d930e2b22f0bee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-win_amd64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-win_amd64.whl
Size 106.8 kB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b2e98afb0fafb5fcf476c608409eb6cde32fa351a6e08001a38457905080c6d7
BLAKE2b-256 checksum
How to use checksums
2629f0e99b343a730febfb749e364cd09e296c50feaa2109a436a212ff9717dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-musllinux_1_2_x86_64.whl
Size 404.3 kB
Tags CPython 3.11 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
c214d75d590a145c3a112eb2e3a7afdff02fbdbaa66db00aaa42037b7a874b9e
BLAKE2b-256 checksum
How to use checksums
81d2cdfea07346f31afe1aa381d97f451686269cb8b9eaa258589b18f88c9291
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-musllinux_1_2_aarch64.whl
Size 365.4 kB
Tags CPython 3.11 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
42c1b3679122a3b88ddd932f1b2731df72dd384a89b13ffb045c96eaf383ba1a
BLAKE2b-256 checksum
How to use checksums
d41e5cb294968284769e8365a99a4143a6f78eb4f165b0f5055d626090b0fb33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-manylinux_2_28_x86_64.whl
Size 192.4 kB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
08cddd650c4495d5521b067d5640151b159f73dbf116703447ecf1df72faec6c
BLAKE2b-256 checksum
How to use checksums
ee104bc3db4bb58c05f4ad618191236bebd965be43b8f40f0b37ab98917a5f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl
Size 187.4 kB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
b80669da6f533df32a67c7f83081cf6897e0f1ee5095d7bb46a4d36a06ec99d9
BLAKE2b-256 checksum
How to use checksums
fa87e214a1c5c2d63184ae018c5b461be5dc265a3c7242bf3fcb07b97d3b9d5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Size 180.7 kB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5b880bd1d6c47a0893c9dd6862d10db7bc3574adedf77eeb23cb505a3a66d6de
BLAKE2b-256 checksum
How to use checksums
fc47cd6267bf4da6bcf7dd619819d5665eea5e36a371bf4aad04698b43cc33c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / fast_math_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL fast_math_rs-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 187.8 kB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
35049451e9a9def87ca199c87dd206037ac2f4871705dee4e7010cf9a0efd1e8
BLAKE2b-256 checksum
How to use checksums
3f821592395ffc62e76a74cffd7ddeb322d17a5d6efe100e030bab6b84bc04d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for fast-math-rs 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 15 files in this release have been uploaded with provenance metadata.

Select from 15 files

Attestation for fast_math_rs-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

15 release files Full provenance

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