regular expressions questions

Tom Culliton culliton at clark.net
Fri Mar 31 16:15:39 EST 2000


In article <010001bf9acf$500cff00$d4c2043f at spkydomain>,
David Fisher <python at rose164.wuh.wustl.edu> wrote:
> This statement suprised me.  I had gotten the impression from
> lurking in the newsgroup that the functions in the string module
> were as fast or faster for many operations.

You misunderstood the statement.  The string module is mainly a front
for the strop module written in C which is faster for the cases where
you can use it.

>Is re really that much faster that string?

No, of course not, unless it lets you do something in one go that
would take you many string operations and connecting logic in python.

Doing string.find will generally be faster than doing re.search for
simple strings, because re.search is a more complex operation.  On the
other hand doing a complex re.sub will be faster than emulating it
with several string operations.



More information about the Python-list mailing list