String search vs regexp search
Anand Pillai
pythonguy at Hotpop.com
Wed Oct 15 04:21:45 EDT 2003
Small point. If you notice the code, compilation time is
not included in the actual time calculated for regexp.
-Anand
tweedgeezer at hotmail.com (Jeremy Fincher) wrote in message news:<698f09f8.0310132019.4bd918b2 at posting.google.com>...
> 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