String search vs regexp search

Dennis Reinhardt DennisR at dair.com
Tue Oct 14 02:19:40 EDT 2003


>  I find that the string search
> is at least 2 times faster than the one with regexp
>     r=re.compile(substr, re.IGNORECASE)

Off the top, maybe the regex is taking twice the time because it is doing
twice the work looking for both the lower case character and the upper case
character.  It does not seem a fair test because the string find is case
sensitive.
-- 

Dennis Reinhardt

DennisR at dair.com   http://www.spamai.com?ng_py






More information about the Python-list mailing list