Python speed and `pcre'
Andrew M. Kuchling
akuchlin at mems-exchange.org
Tue Aug 31 17:46:00 EDT 1999
François Pinard <pinard at iro.umontreal.ca> writes:
> * Python cache for compiled REGEXP is less virtuous than I imagined.
re.py caches the last 20 patterns used; you could set _MAXCACHE to a
higher value and see if that helps (though it'll probably break when
re.py is rewritten as C). Have you actually found that the slow-down
is coming from compilation time, and not execution time? Perl's regex
engine has more optimizations than PCRE does, so if the problem is the
actual execution of the regex, then playing with different caching
mechanisms isn't going to help anything.
> Is there something fundamental I am missing, and some just simpler code
> that would have the desired effect? Or else, is there another approach
> that could give me more speed without giving too much on legibility?
> I'm surely ready to accept some slowdown going from Perl to Python, but
> a slowdown factor or 10 is a bit much, in my opinion.
I'd be interested in seeing some of the patterns being used; perhaps
some of them are patterns that are handled well by Perl's engine, and
poorly by PCRE.
A.M. Kuchling http://starship.python.net/crew/amk/
Problems worthy of attack / prove their worth by hitting back.
-- Piet Hein
More information about the Python-list