optimization question

Bernard Delmée bdelmee at advalvas._ZAPME_.be
Sun Aug 11 21:45:29 CEST 2002


>         def eqsub(s, i, j, t):
>                 return (len(t) == j-i) and s[i:j] == t
>
> which avoids building the substrings unless necessary.
>

Wouldn't the following avoid it altogether?

    return (len(t) == j-i) and (s.find(t,i) != -1)






More information about the Python-list mailing list