A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-February/051599.html below:

[Python-Dev] string find(substring) vs. substring in string

[Python-Dev] string find(substring) vs. substring in string [Python-Dev] string find(substring) vs. substring in stringIrmen de Jong irmen at xs4all.nl
Wed Feb 16 22:08:36 CET 2005
Mike Brown wrote:
> Fredrik Lundh wrote:
> 
>>any special reason why "in" is faster if the substring is found, but
>>a lot slower if it's not in there?
> 
> 
> Just guessing here, but in general I would think that it would stop searching 
> as soon as it found it, whereas until then, it keeps looking, which takes more 
> time. But I would also hope that it would be smart enough to know that it 
> doesn't need to look past the 2nd character in 'not the xyz' when it is 
> searching for 'not there' (due to the lengths of the sequences).

There's the Boyer-Moore string search algorithm which is
allegedly much faster than a simplistic scanning approach,
and I also found this: http://portal.acm.org/citation.cfm?id=79184
So perhaps there's room for improvement :)

--Irmen
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4