Raymond Hettinger added the comment:
Closing for the reasons listed above.
--
resolution: - rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13396
___
Changes by Jesús Cea Avión j...@jcea.es:
--
nosy: +jcea
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13396
___
___
Python-bugs-list mailing list
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
priority: normal - low
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13396
___
___
New submission from Amaury Forgeot d'Arc amaur...@gmail.com:
I noticed that several usages of random.getrandbits() actually need bytes. A
few examples:
- Lib/test/test_zlib.py calls random.getrandbits(8 * _1M).to_bytes()
- Twisted uses the %x format and then call .decode('hex')
Another
Changes by Nadeem Vawda nadeem.va...@gmail.com:
--
nosy: +nadeem.vawda
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13396
___
___
Antoine Pitrou pit...@free.fr added the comment:
Good idea, IMO.
+cum = set()
+for i in range(100):
+val = getbytes(span)
+cum |= set(i for i in range(span) if val[i])
+self.assertEqual(len(cum), span)
I find this test a bit
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: - rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13396
___
___
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
How would this work for other random number generators that don't supply
genrand_int32()?
The API for random is supposed to be easily subclassable and reusable for other
random number generators. The requirements for those
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
How would this work for other random number generators that don't
supply genrand_int32()?
genrand_int32 is an internal function, only available in C for the Mersenne
Twister generator.
random.SystemRandom() should provide
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
genrand_int32 is an internal function,
only available in C for the Mersenne Twister generator.
Yes, I know. I'm the one added that code ;-)
I don't know other generators.
The problem is that we need an API that will
Antoine Pitrou pit...@free.fr added the comment:
The problem is that we need an API that will accommodate other random
number generators and not be specific to the MersenneTwister. Right
now, the starting point for everything in the random module is an
underlying generator supplying a
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
./python -m timeit -s from random import getrandbits
getrandbits(800).to_bytes(100, 'little')
10 loops, best of 3: 25 msec per loop
./python -m timeit -s from random import getrandbytes getrandbytes(100)
100 loops, best of
Changes by Amaury Forgeot d'Arc amaur...@gmail.com:
Removed file: http://bugs.python.org/file23679/getrandbytes.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13396
___
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
The differential cost of generating n random bytes is negligible compared to
actually doing anything with the bytes once their generated.
This optimization is close to being a total waste (saving 15 milliseconds for
the
14 matches
Mail list logo