[pygtk] Re: [Tutor] pattern matching is too slow
vinayvinay at gmail.com
Fri Aug 12 17:40:55 WST 2005
> I'd recommend yanking the regular expression compilation out of the inner
> loop, and just reuse the regex object after you compile it once.
Sorry, it was my mistake. The errror was elsewhere. I cleaned up my
code and suddently it started working fine. I guess python can do the
simple optimization of moving the regex compilation outside the while
> By the way, there are other things in this program that should be fixed.
> The way it reads lines from the file is non-idiomatic. For an example of
> what people will usually do to go through a file's lines, see a tutorial
> like Alan Gauld's "Learning to Program":
Thanks a lot for the link. The 'idiomatic' way is pretty elegant.
More information about the pygtk