[Tutor] A file containing a string of 1 billion random digits.
bob gailer
bgailer at gmail.com
Sun Jul 18 20:07:27 CEST 2010
Check this out:
import random, time
s = time.time()
cycles = 1000
d = "0123456789"*100
f = open("numbers.txt", "w")
for i in xrange(n):
l = []
l.extend(random.sample(d, 1000))
f.write(''.join(l))
f.close()
print time.time() - s
1 million in ~1.25 seconds
Therefore 1 billion in ~21 minutes. 3 ghz processor 2 g ram.
Changing length up or down seems to increase time.
--
Bob Gailer
919-636-4239
Chapel Hill NC
More information about the Tutor
mailing list