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 -- http://mail.python.org/mailman/listinfo/python-list