optimization question
Andrew Koenig
ark at research.att.com
Sun Aug 11 18:13:06 EDT 2002
>> def eqsub(s, i, j, t):
>> return (len(t) == j-i) and s[i:j] == t
>>
>> which avoids building the substrings unless necessary.
>>
Bernard> Wouldn't the following avoid it altogether?
Bernard> return (len(t) == j-i) and (s.find(t,i) != -1)
Yes, it looks like it would. On the other hand, I might want
to generalize the technique to sequences other than strings...
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list