Precompiled regular expressions slower?
Peter Bienstman
pbienst at MIT.EDU
Tue Feb 26 13:43:32 EST 2002
On Tue, 2002-02-26 at 13:36, Sean 'Shaleh' Perry wrote:
>
> On 26-Feb-2002 Peter Bienstman wrote:
> >> Perhaps Peter should post the relevant code so we can see what is actually
> >> happening for ourselves?
> >
> > Here is the relevant portion of the code:
(this was the fastest, orginal version, i.e without precompiling)
> After changing things as Jon Ribbens explains did you get a sufficient speed
> boost?
Changing from precompiling to a global var to precompiling to a local
var improved performance a bit, but still the non-precompiled version
was faster.
> My only other comment would be one of style and efficiency. In the loop you
> check the line against numerous regexs. Would each line really match more than
> one or two of those? Perhaps a few strategic calls to continue may help.
Interesting tip, thanks.
Does't explain the slowdown of precompiled reg ex's, though.
Peter
More information about the Python-list
mailing list