fastrand provides significantly faster random number generation in Python compared to the standard `random` module, implemented as a C extension. It is suitable for applications where speed is critical and cryptographic security is not required. The current version is 3.0.8, with a maintenance cadence of small patches and occasional feature additions.
pip install fastrandVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import the fastrand module and use its primary functions: `pcg32bounded` for bounded integers, `pcg32` for unbounded 32-bit unsigned integers, and `randdouble` for floating-point numbers between 0 (inclusive) and 1 (exclusive).
For cryptographically secure random numbers, use Python's `secrets` module (e.g., `secrets.randbelow`, `secrets.token_hex`) or `os.urandom()`.
Carefully review the `fastrand` documentation for the correct function names and signatures. Do not assume `fastrand.randint()` or `fastrand.seed()` will work as they do in the `random` module.
Rely on fastrand's internal seeding mechanism. If explicit, repeatable seeding is required, consider using Python's standard `random` module or a different library that exposes such an API.
Run `pip install fastrand` in your terminal to install the library.
Use `fastrand.pcg32bounded(N)` to get a random integer in the range [0, N-1].
Provide a positive integer argument to `pcg32bounded()`, e.g., `fastrand.pcg32bounded(100)` for numbers 0-99.
No dependency data recorded yet.