shuffle the lines of a large file
Simon Brunning
simon.brunning at gmail.com
Thu Mar 10 09:11:31 EST 2005
On Thu, 10 Mar 2005 14:37:25 +0100, Stefan Behnel <stefan.behnel-n05pAM at web.de>
> There. Factor 10. That's what I call optimization...
The simplest approach is even faster:
C:\>python -m timeit -s "from itertools import repeat" "[None for i in
range(10000)]"
100 loops, best of 3: 2.53 msec per loop
C:\>python -m timeit -s "from itertools import repeat" "[None for i in
xrange(10000)]"
100 loops, best of 3: 2.45 msec per loop
C:\>python -m timeit -s "from itertools import repeat"
"list(repeat(None, 10000))"
1000 loops, best of 3: 245 usec per loop
C:\>python -m timeit -s "from itertools import repeat" "[None] * 10000"
10000 loops, best of 3: 160 usec per loop
;-)
BTW, I've posted a more general version here:
http://www.brunningonline.net/simon/blog/archives/001784.html
--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/
More information about the Python-list
mailing list