Tom Funk _spam_sux_tdfunk at
Thu Mar 23 19:39:05 CET 2000

In an article posted 22 Mar 2000 19:55:11 GMT,
Dana Booth (dana at said:
> Is readline() not very efficiant? 
> [snip]
> Anyway, I'm pretty new to Python, is there a better way to analyze
> textfiles? Or is the slowing it down?

Anytime you want to optimize an app for speed, regardless of programming 
language used, step one should always be to profile the code.  This will 
give you a definitive picture of where your code is slowest, and where to 
focus your efforts.

Luckily Python comes with a profiler (man, I love this language :-). 
Section 10, "The Python Profiler":

discusses this module.

After you profile your code, and if the re or string modules turn out to 
be the bottleneck for your code, you might take a look at Marc-Andre 
Lemburg's mxTextTools module.  I've fiddled with it a little bit and for 
text pattern matching it goes like a bat out of hell. ;-)


However, before you start massively tweaking you code, do yourself a 
favor and profile it.  That one step could be very enlightening.

-=< tom >=-
Thomas D. Funk                           |       "Software is the lever
Software Engineering Consultant          | Archimedes was searching for"
Advanced Systems Design, Tallahassee FL. |

More information about the Python-list mailing list