amk at amk.ca
Fri Oct 29 20:51:16 CEST 2004
On Fri, 29 Oct 2004 20:35:28 +0200,
Reinhold Birkenfeld <reinhold-birkenfeld-nospam at wolke7.net> wrote:
> But my actual question is why Perl can run the same regexes in what
> seems no time at all.
Probably Perl's engine does some particular bit of optimization that
Python's engine isn't doing. I have no idea what optimization that might
> But /usr/lib/python2.3/sre*.py are relatively large for that; what's in
That code is the compiler that turns expressions into the bytecode that the
regex engine runs. Having it be in Python only matters to the performance
of re.compile(), and that function usually isn't a bottleneck.
> You're right again. Is the pre module using the PCRE C library?
An extensively hacked version of it. Modules/pypcre.c contains the bulk of
it; pcremodule.c is the Python interface to it.
More information about the Python-list