Comments (5)
Can you elaborate ?
This library is not really about number generation per se, but rather about a faster replacement for random.randint
.
Please describe what you are trying to do.
from fastrand.
I try to generate binary number's in length from 68 to 120 bits(0 and 1).
random.randint is too slow for me, and not get result.
I compare all generated numbers for ex,thith this 60 bit lenght number:
0b010110010001111011101000010000011101011010111110101010111100
And then I find number, code break.
???
Thank you very mach for your answers !!
from fastrand.
So call fastrand.xorshift128plus() & 0x3ffffffffffffff
to get a 58-bit random number. For a 59-bit number, do fastrand.xorshift128plus() & 0x7ffffffffffffff
. It should be fast:
$ python3 -m timeit -s 'import random' 'random.randint(0,0x3ffffffffffffff)'
1000000 loops, best of 5: 371 nsec per loop
$ python3 -m timeit -s 'import fastrand' 'fastrand.xorshift128plus() & 0x3ffffffffffffff'
5000000 loops, best of 5: 42 nsec per loop
from fastrand.
If you need a 120 bits, call fastrand.xorshift128plus()
to get a 64-bit number, then call fastrand.xorshift128plus() & 0xffffffffffffff
to get the remaining 56 bits.
from fastrand.
Thank you so mach, Mister ))
from fastrand.
Related Issues (17)
- Add package to pip for macos HOT 3
- Seeding HOT 5
- "pip install fastrand" prefers to install version1.1 instead of 1.2 HOT 2
- Seeding many generators causes fastrand to crash HOT 2
- Should the result of pcg32() be signed? HOT 6
- Enhancment: Add option for bounded randoms such randint in numpy and python.random HOT 2
- How to Guess Upper/Lower bound of a fastrand ? HOT 4
- Error when installing from pip/building HOT 2
- On latest python 2.7 your library is faster HOT 1
- OverflowError when generating random int for large numbers HOT 2
- How pcg32_random_bounded_divisionless() work ? HOT 23
- pcg32bounded argument check HOT 8
- Is it possible to have a seed? HOT 2
- Support for Windows HOT 3
- Python3 installation HOT 2
- Add package to pip HOT 28
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastrand.