regular expressions questions

Fredrik Lundh effbot at
Fri Mar 31 12:46:31 CEST 2000

David Fisher wrote:
> [snip]
> > Text searching is currently best done with re which is vastly faster
> > any Python code.
> [snip]
> This statement suprised me.  I had gotten the impression from lurking in
> newsgroup that the functions in the string module were as fast or faster
> 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).


More information about the Python-list mailing list