fastrand 3.0.5__cp310-cp310-win_amd64.whl → 3.0.7__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fastrand might be problematic. Click here for more details.
- {fastrand-3.0.5.dist-info → fastrand-3.0.7.dist-info}/METADATA +147 -104
- fastrand-3.0.7.dist-info/RECORD +6 -0
- {fastrand-3.0.5.dist-info → fastrand-3.0.7.dist-info}/WHEEL +1 -1
- fastrand-3.0.7.dist-info/top_level.txt +2 -0
- fastrand.cp310-win_amd64.pyd +0 -0
- fastrand-3.0.5.dist-info/RECORD +0 -6
- fastrand-3.0.5.dist-info/top_level.txt +0 -1
- {fastrand-3.0.5.dist-info → fastrand-3.0.7.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,104 +1,147 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: fastrand
|
|
3
|
-
Version: 3.0.
|
|
4
|
-
Summary: Fast random number generation in Python
|
|
5
|
-
Author: Daniel Lemire
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
fastrand
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fastrand
|
|
3
|
+
Version: 3.0.7
|
|
4
|
+
Summary: Fast random number generation in Python
|
|
5
|
+
Author-email: Daniel Lemire <daniel@lemire.me>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/lemire/fastrand
|
|
8
|
+
Project-URL: Repository, https://github.com/lemire/fastrand
|
|
9
|
+
Project-URL: Issues, https://github.com/lemire/fastrand/issues
|
|
10
|
+
Keywords: random,random-number-generator,pcg,xorshift,performance
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: C
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# fastrand
|
|
30
|
+
|
|
31
|
+
Fast random number generation in an interval in Python: Up to 10x faster than random.randint.
|
|
32
|
+
|
|
33
|
+
Blog post: [Ranged random-number generation is slow in Python](https://lemire.me/blog/2016/03/21/ranged-random-number-generation-is-slow-in-python/)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Usage...
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import fastrand
|
|
42
|
+
|
|
43
|
+
print("generate an integer in [0,1001)")
|
|
44
|
+
fastrand.pcg32bounded(1001)
|
|
45
|
+
print("generate an integer in [100,1000]")
|
|
46
|
+
fastrand.pcg32randint(100,1000) # requires Python 3.7 or better
|
|
47
|
+
print("Generate a random 32-bit integer.")
|
|
48
|
+
fastrand.pcg32()
|
|
49
|
+
print("Generate a number in [0,1).")
|
|
50
|
+
fastrand.pcg32_uniform()
|
|
51
|
+
|
|
52
|
+
if fastrand.SIXTYFOUR: # support for xorshift128+ is limited to some 64-bit platforms (linux, macos, etc.)
|
|
53
|
+
print("generate an integer in [0,1001)")
|
|
54
|
+
fastrand.xorshift128plusbounded(1001)
|
|
55
|
+
print("generate an integer in [100,1000]")
|
|
56
|
+
fastrand.xorshift128plusrandint(100,1000) # requires Python 3.7 or better
|
|
57
|
+
print("Generate a random 64-bit integer.")
|
|
58
|
+
fastrand.xorshift128plus()
|
|
59
|
+
print("Generate a number in [0,1).")
|
|
60
|
+
fastrand.xorshift128plus_uniform()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
We also include functions for fast float generation.
|
|
64
|
+
|
|
65
|
+
It is nearly an order of magnitude faster than the alternatives:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
python3 -m timeit -s 'import fastrand' 'fastrand.pcg32bounded(1001)'
|
|
70
|
+
10000000 loops, best of 5: 23.6 nsec per loop
|
|
71
|
+
|
|
72
|
+
python3 -m timeit -s 'import fastrand' 'fastrand.pcg32randint(100,1000)'
|
|
73
|
+
10000000 loops, best of 5: 24.6 nsec per loop
|
|
74
|
+
|
|
75
|
+
python3 -m timeit -s 'import random' 'random.randint(0,1000)'
|
|
76
|
+
1000000 loops, best of 5: 216 nsec per loop
|
|
77
|
+
|
|
78
|
+
# if you have numpy:
|
|
79
|
+
python3 -m timeit -s 'import numpy' 'numpy.random.randint(0, 1000)'
|
|
80
|
+
500000 loops, best of 5: 955 nsec per loop
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The pcg32 generator is a 32-bit generator so it generates values in the interval from `0` to `2**32-1`.
|
|
85
|
+
The xorshift128+ generator is a 64-bit generator so that it can generate values in a 64-bit range (up to `2**64-1`).
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## Installation
|
|
89
|
+
|
|
90
|
+
If you have Linux, macOS or Windows, you should be able to do just pip install...
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install fastrand
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
You may need root access (sudo on macOS and Linux).
|
|
97
|
+
|
|
98
|
+
It is sometimes useful to install a specific version, you can do so as follows:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install fastrand==1.2.4
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Using uv (recommended)
|
|
105
|
+
|
|
106
|
+
[uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver.
|
|
107
|
+
|
|
108
|
+
To add fastrand as a dependency to your project:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
uv add fastrand
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Or to install it directly into your current environment:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
uv pip install fastrand
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Building from source
|
|
121
|
+
|
|
122
|
+
With uv:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
uv build
|
|
126
|
+
uv pip install dist/*.whl
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Or with standard tools:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pip install build
|
|
133
|
+
python -m build
|
|
134
|
+
pip install dist/*.whl
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## Changing the seed and multiple streams
|
|
139
|
+
|
|
140
|
+
- You can change the seed with a function like `pcg32_seed`. The seed determines the random values you get. Be mindful that naive seeds (e.g., `int(time.time())`) can deliver poor initial randomness. A few calls to `pcg32()` may help to boost the improve the randomness. Or else you may try a better seed.
|
|
141
|
+
- If you need to produce multiple streams of random numbers, merely changing the seed is not enough. You are better off using different increments by calling the `pcg32inc`. The increments should all be distinct. Note that the least significant bit of the increment is always set to 1 no matter which value you pass: so make sure your increments are distinct 31-bit values (ignoring the least significant bit).
|
|
142
|
+
- You may also initialize xorshift128+ with `xorshift128plus_seed1` and `xorshift128plus_seed2`.
|
|
143
|
+
|
|
144
|
+
## Reference
|
|
145
|
+
|
|
146
|
+
* http://www.pcg-random.org
|
|
147
|
+
* Daniel Lemire, [Fast Random Integer Generation in an Interval](https://arxiv.org/abs/1805.10941), ACM Transactions on Modeling and Computer Simulation, Volume 29 Issue 1, February 2019
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
fastrand.cp310-win_amd64.pyd,sha256=YDzqZcaPcBrvxEtSixi2QiqoB5r4iLaUKbyjycDW0_U,14336
|
|
2
|
+
fastrand-3.0.7.dist-info/licenses/LICENSE,sha256=4DukHX-rIHAHaf5BGLq1DYAMt0-ZA1OgXS9f_xwig2M,11558
|
|
3
|
+
fastrand-3.0.7.dist-info/METADATA,sha256=4-LxrJ58KLf7FZICRmcpAkGaC-8QA2A_DmufZr14Z_M,5086
|
|
4
|
+
fastrand-3.0.7.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
|
|
5
|
+
fastrand-3.0.7.dist-info/top_level.txt,sha256=hP1UU0jrDjL5G11OfRmlRKfqliLNNwcD51wtEzKsIlU,20
|
|
6
|
+
fastrand-3.0.7.dist-info/RECORD,,
|
fastrand.cp310-win_amd64.pyd
CHANGED
|
Binary file
|
fastrand-3.0.5.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
fastrand.cp310-win_amd64.pyd,sha256=0q8QSfl_h_e5v2qdScbKT4hh5hoqK7fYsrNcpnnY-Uc,14336
|
|
2
|
-
fastrand-3.0.5.dist-info/LICENSE,sha256=4DukHX-rIHAHaf5BGLq1DYAMt0-ZA1OgXS9f_xwig2M,11558
|
|
3
|
-
fastrand-3.0.5.dist-info/METADATA,sha256=owEgXbHVEfvtUClfdx2yyh7YvC0tm5BSb8gTr_2SYII,3597
|
|
4
|
-
fastrand-3.0.5.dist-info/WHEEL,sha256=W26pYN7HLsBT1jrDSL9udgf_mdNKJmYmL23sIP-FcgM,102
|
|
5
|
-
fastrand-3.0.5.dist-info/top_level.txt,sha256=Z3tGZhQlNI6bOnJeYeHyE5sSKqud1hxYNfa7SX5Bm4U,9
|
|
6
|
-
fastrand-3.0.5.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fastrand
|
|
File without changes
|