Reading just a few lines from a text file
Paul McGuire
ptmcg at austin.rr.com
Tue Aug 23 17:54:36 EDT 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
seconds.
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.
-- Paul
More information about the Python-list
mailing list