String search vs regexp search
Jeremy Fincher
tweedgeezer at hotmail.com
Tue Oct 14 00:19:12 EDT 2003
Duncan Booth <duncan at NOSPAMrcp.co.uk> wrote in message news:<Xns941360C9B9445duncanrcpcouk at 127.0.0.1>...
> The regular expression code has a startup penalty since it has to compile
> the regular expression at least once, however the actual searching may be
> faster than the naive str.find. If the time spent doing the search is
> sufficiently long compared with the time doing the compile, the regular
> expression may win out.
Both regular expression searching and string.find will do searching
one character at a time; given that, it seems impossible to me that
the hand-coded-in-C "naive" string.find could be slower than the
machine-translated-coded-in-Python regular expression search.
Compilation time only serves to further increase string.find's
advantage.
Jeremy
More information about the Python-list
mailing list