which one is faster?
Jonathan Gardner
jgardner at jonathangardner.net
Fri Jan 29 17:27:19 EST 2010
On Jan 28, 10:29 pm, "Stephen.Wu" <54wut... at gmail.com> wrote:
> str.find(targetStr)
> str.index(targetStr) with exception
> str.count(targetStr)
> targetStr in str
>
> which is the fastest way to check whether targetStr is in str?
>
The fastest way of all is to forget about this and finish the rest of
your program. Developer time is much, much more valuable than
processor time.
When you are all done, and have solved all the other problems in the
world, you can come back and pontificate on how many nanoseconds you
can save by using "find" or "in".
More information about the Python-list
mailing list