file seek is slow

Paul McGuire ptmcg at austin.rr.com
Tue Mar 9 19:11:35 EST 2010


This is a pretty tight loop:

for i in xrange(1000000):
       f1.seek(0)

But there is still a lot going on, some of which you can lift out of
the loop.  The easiest I can think of is the lookup of the 'seek'
attribute on the f1 object.  Try this:

f1_seek = f1.seek
for i in xrange(1000000):
       f1_seek(0)

How does that help your timing?

-- Paul



More information about the Python-list mailing list