[Python-Dev] RE: [String-SIG] Re: regexp performance

Tim Peters tim_one@email.msn.com
Thu, 11 Nov 1999 02:03:34 -0500


[Andrew M. Kuchling]
> ...
> Friedl's book describes several optimizations which aren't implemented
> in PCRE.  The problem is that PCRE never builds a parse tree, and
> parse trees are easy to analyse recursively.  Instead, PCRE's
> functions actually look at the compiled byte codes (for example, look
> at find_firstchar or is_anchored in pypcre.c), but this makes analysis
> functions hard to write, and rearranging the code near-impossible.

This is wonderfully & ironically Pythonic.  That is, the Python compiler
itself goes straight to byte code, and the optimization that's done works at
the latter low level.  Luckily <wink>, very little optimization is
attempted, and what's there only replaces one bytecode with another of the
same length.  If it tried to do more, it would have to rearrange the code
...

the-more-things-differ-the-more-things-don't-ly y'rs  - tim