https://github.com/mukundan314/python-fastrand
A pure python clone of lemire/fastrand
https://github.com/mukundan314/python-fastrand
Last synced: about 1 month ago
JSON representation
A pure python clone of lemire/fastrand
- Host: GitHub
- URL: https://github.com/mukundan314/python-fastrand
- Owner: Mukundan314
- License: mit
- Created: 2019-03-29T05:11:41.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-29T16:50:51.000Z (about 6 years ago)
- Last Synced: 2025-03-02T11:44:42.202Z (2 months ago)
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-fastrand
A pure python clone of [lemire/fastrand](https://github.com/lemire/fastrand)
## Installation
With `pip`:
```shell
pip install python-fastrand
```From source:
```
git clone https://github.com/mukundan314/python-fastrand.git
cd python-fastrand
python setup.py install
```## Usage
All methods are compatible with the ones in [lemire/fastrand](https://github.com/lemire/fastrand) provided in the `pyfastrand` module
```
>>> import pyfastrand
>>> pyfastrand.pcg32bounded(1000)
498
>>> pyfastrand.pcg32()
1547545700
```## Benchmarks
Speed of functions when gernerating a random number in the range of 0 to 1000
```shell
$ bash benchmark.sh
_random.Random().random
2000000 loops, best of 5: 156 nsec per loopfastrand.pcg32
2000000 loops, best of 5: 137 nsec per loopfastrand.pcg32bounded
5000000 loops, best of 5: 78.2 nsec per loopos.urandom
500000 loops, best of 5: 865 nsec per looppyfastrand.pcg32
500000 loops, best of 5: 634 nsec per looppyfastrand.pcg32bounded
500000 loops, best of 5: 749 nsec per looprandom.randint
500000 loops, best of 5: 822 nsec per looprandom.random
2000000 loops, best of 5: 169 nsec per loop
```