> > Oops, that should be s.find(t,i,j) > Right, but we'd still potentially scan megabytes. How about: (s.find(t,i,min(j,i+len(t)) == i) Erh... which, provided I got it right this time, isn't nearly as obviously readable as the original test...