Boyer-Moore and variants need a bit of preprocessing on the pattern which
makes them great for long patterns but more costly for short ones.
On Wed, 16 Feb 2005, Irmen de Jong wrote:
> Mike Brown wrote:
> > Fredrik Lundh wrote:
> >
> >>any special reason why "in" is faster if the substring is fo
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 mo
> Assuming stringobject.c:string_contains is the right function, the
> code looks like this:
>
> size = PyString_GET_SIZE(el);
> rhs = PyString_AS_STRING(el);
> lhs = PyString_AS_STRING(a);
>
> /* optimize for a single character */
> if (size == 1)
>
On Wed, Feb 16, 2005 at 01:34:16PM -0700, Mike Brown wrote:
> 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).
Assuming stringobje
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
Title: RE: [Python-Dev] string find(substring) vs. substring in string
[Fredrik Lundh]
#- any special reason why "in" is faster if the substring is found, but
#- a lot slower if it's not in there?
Maybe because it stops searching when it finds it?
The time seems to be ve