_spam_sux_tdfunk at _spam_sux_nettally.com
Thu Mar 23 19:39:05 CET 2000
In an article posted 22 Mar 2000 19:55:11 GMT,
Dana Booth (dana at mmi.oz.net) said:
> Is readline() not very efficiant?
> Anyway, I'm pretty new to Python, is there a better way to analyze
> textfiles? Or is the re.search 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