Python 3 read() function

Istvan Albert istvan.albert at gmail.com
Thu Dec 4 21:40:34 CET 2008


Turns out write performance is also slow!

The program below takes

 3 seconds on python 2.5
17 seconds on python 3.0

yes, 17 seconds! tested many times in various order. I believe the
slowdowns are not constant (3x) but some sort of nonlinear function
(quadratic?) play with the N to see it.

===================================

import time

start = time.time()

N = 10**6
fp = open('testfile.txt', 'wt')
for n in range(N):
    fp.write( '%s\n' % n )
fp.close()

end = time.time()

print (end-start)



More information about the Python-list mailing list