Reading just a few lines from a text file
ptmcg at austin.rr.com
Tue Aug 23 23:54:36 CEST 2005
Are you sure this is really slowing down your program? "Many hundreds
of lines" is not nearly enough to start Python breathing hard. I have
been really impressed with just how quickly Python is able to do file
input and processing, zipping through whole megs of data in just
How are you currently reading the file in? A character at a time?
That *will* be slow. Try file.readlines(), or xreadlines(), and spin
off the last 20 in the list.
More information about the Python-list