"John" <[EMAIL PROTECTED]> writes:
> This works but is a bit slow, I guess I'll have to live with it.
> Any chance this could be sped up in python?

Whoops, I meant to say:

  len([1 for i in xrange(len(s1)) if s1.startswith(s2,i)])

That avoids creating a lot of small strings.

If s1 is large you may want to use fancy algorithms like Boyer-Moore
string search.  If s2 is also large, you could have some kind of
finite state machine scan through s1 so it recognizes overlapping
occurrences of s2 in parallel.  There might be some way to combine
that with Boyer-Moore.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to