Generating a large random string

Sean Ross sross at connectmail.carleton.ca
Thu Feb 19 21:01:15 EST 2004


"Paul Rubin" <http://phr.cx@NOSPAM.invalid> wrote in message
news:7x65e2ikqi.fsf at ruckus.brouhaha.com...
> "Sean Ross" <sross at connectmail.carleton.ca> writes:
> > 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.
>
> On Linux, this is almost instantaneous.  Reading 1 megabyte takes
> under a second on my 700 mhz P3.

And when you've done

s = open("/dev/urandom").read(1000000)

is s a string containing one million letters [a-zA-Z] and no other
types of characters, as the OP is looking for?

I've never used /dev/urandom, so I don't know what kind of stuff
is being read from there - but I suspect further processing would
be needed to meet the OP's requirements. I'll check it out.

Thanks
Sean





More information about the Python-list mailing list