Matching zero only once using RE

Fredrik Lundh fredrik at pythonware.com
Fri Oct 7 19:34:59 EDT 2005


Mike Meyer wrote:

> I think it's time to form a Committee for the Prevention of Regular
> Expression Abuse.

on the other hand, the RE engine uses a more advanced scanning
algorithm than string find, which means that constant RE:s can in
fact be faster under some circumstances (certain patterns, target
strings with lots of false partial matches, etc).

see "searching for literal text" on this page

    http://mail.python.org/pipermail/python-dev/2000-August/007797.html

for some figures.

(things have improved since then, especially in 2.4.  in 2.3, "in" was
also a lot slower than "find".  and all three are still slower than they
have to be: http://online.effbot.org/2004_08_01_archive.htm#find2 )

</F>






More information about the Python-list mailing list