> Wouldn't the following avoid it altogether? > > return (len(t) == j-i) and (s.find(t,i) != -1) Actually (s.find(t,i,i)==i) is best, since you don't want to search to the end of the string (which, as originally stated may be megabytes). - Matt