Generating a large random string
sross at connectmail.carleton.ca
Fri Feb 20 02:29:33 CET 2004
"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7xsmh6a7cd.fsf at ruckus.brouhaha.com...
> import array
> from random import randint
> d = array.array('B')
> for i in xrange(1000000):
> s = d.tostring()
Actually, that is pretty slow: 42.79s (on my machine)
The OP's solution took 23.94s
My sampling with replacement took 7.68s
No doubt someone else will come up with something faster.
I'd be interested to see how
s = open("/dev/urandom").read(3000)
compares, and, if better, whether something similar can
be done on Windows.
More information about the Python-list