file seek is slow

Metalone jcb at iteris.com
Fri Mar 12 20:53:28 CET 2010


I almost wrote a long reply to all this.
In the end it boils down to being concerned about how much overhead
there is to calling a 'C' function.
I assumed that file.seek() simply delegated to fseek() and thus was
one way to test this overhead.
However, I now think that it must be doing more and may not be a
reasonable comparison.

I have used the profiler about as much as I can to find where my
program is slow, and it appears to me that
the overhead to calling 'C' functions is now my biggest problem.
I have been using Ctypes, which has been a great tool so far.
I just discovered Cython and this looks like it may help me.
I had not heard of pythoid, so I will check it out.

I did not mean to offend anybody in Cython community.
It just seemed funny to me that 21 lines of Python became 1478 lines
of 'C'.
I wasn't really expecting any response to this.
I don't know enough about this to really assume anything.

Stephan,
I just tested 1e7 loops.
'C': 8.133 seconds
Cython: 10.812 seconds

I can't figure out what Cython is using for CFLAGS, so this could be
important.

I used While instead of xrange, because I thought it would be faster
in Cython.
They had roughly the same execution speed.

Thanks all for the suggestions.
I think I will just consider this thread closed.





More information about the Python-list mailing list