[pygtk] Re: [Tutor] pattern matching is too slow
Vinay Reddy
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
loop.
> 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":
>
> http://www.freenetpages.co.uk/hp/alan.gauld/tutfiles.htm
Thanks a lot for the link. The 'idiomatic' way is pretty elegant.
Regards,
Vinay
More information about the pygtk
mailing list