Perl speed vs. Python speed

Tom Culliton culliton at clark.net
Wed Jan 12 11:29:44 EST 2000


In article <00f801bf5d0e$ae601140$f29b12c2 at secret.pythonware.com>,
Fredrik Lundh <fredrik at pythonware.com> wrote:
>Tom Culliton" <culliton at clark.net> wrote:
>> The "new" Python re module needs to be optimized and possibly pushed
>> into C code, the older regex module is about twice as fast.
>
>if everything goes according to plan, 're' (and possibly also
>'regex') will be replaced by a new unicode-aware engine in
>1.6.  I've attached some (somewhat outdated) benchmarks.

Cool.  How much rewriting is it going to require in existing scripts?

>note that 'regex' is faster than 're' only if you apply simple
>regular expressions many times.

Which, I think you'll have to admit, is probably the most common usage.

>if you can reorganize the
>code to use a single regular expression on a larger string,
>'re' beats the hell out of 'regex'.  ...and if you make things
>complicated enough, 'regex' stops working... (but as usual,
>some people prefer to get the wrong answer quickly ;-)

Big complicated regular expressions are a recipe for insanity.  Ask
Tim, and he'll recommend using small simple regular expressions 9
times out of 10.  At least thats how he's responded every time I've
asked about problems with some excessively clever regular expression
here.  Heck, I think you've even told me the same thing on at least
one occasion. ;-)




More information about the Python-list mailing list