[issue13396] new method random.getrandbytes()

2013-07-12 Thread Raymond Hettinger
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 ___

[issue13396] new method random.getrandbytes()

2011-11-14 Thread Jesús Cea Avión
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

[issue13396] new method random.getrandbytes()

2011-11-14 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13396 ___ ___

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Amaury Forgeot d'Arc
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Nadeem Vawda
Changes by Nadeem Vawda nadeem.va...@gmail.com: -- nosy: +nadeem.vawda ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13396 ___ ___

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Antoine Pitrou
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- assignee: - rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13396 ___ ___

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Raymond Hettinger
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Amaury Forgeot d'Arc
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Raymond Hettinger
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Antoine Pitrou
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Amaury Forgeot d'Arc
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

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Amaury Forgeot d'Arc
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 ___

[issue13396] new method random.getrandbytes()

2011-11-13 Thread Raymond Hettinger
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