regular expressions questions

Fredrik Lundh effbot at telia.com
Fri Mar 31 05:46:31 EST 2000


David Fisher wrote:
> [snip]
> > Text searching is currently best done with re which is vastly faster
than
> > any Python code.
> [snip]
>
> 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.
>
> Is re really that much faster that string?

string is usually faster (or at least as fast) on everything that
is implemented by a builtin primitive (or method call, in 1.6).

but re can do much more.

(note that 're' isn't fast because it's using a cryptic syntax, it's fast
because it's using a custom pattern matching engine instead of the
python bytecode interpreter.  neel's original argument was that we
can do better syntax-wise).

</F>





More information about the Python-list mailing list