str.count algorithm

Raymond Hettinger python at rcn.com
Tue May 4 15:25:30 EDT 2010


On May 4, 12:12 pm, Hellnar <dalama... at gmail.com> wrote:
> Hello,
> I am trying to find what algorithm Python uses for the built-in
> str.count function, if it has a name.

Roughly the same as:

   sum(1 for c in s if c == tgt)


Raymond




More information about the Python-list mailing list