From: Hellnar on 4 May 2010 15:12 Hello, I am trying to find what algorithm Python uses for the built-in str.count function, if it has a name. Thanks
From: Raymond Hettinger on 4 May 2010 15:25 On May 4, 12:12 pm, Hellnar <dalama...(a)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
From: Peter Otten on 4 May 2010 15:54 Raymond Hettinger wrote: > On May 4, 12:12 pm, Hellnar <dalama...(a)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) That would be list.count(), I think. OP, the source http://svn.python.org/view/python/trunk/Objects/stringlib/fastsearch.h?revision=77470&view=markup has a reference to http://effbot.org/zone/stringlib.htm Peter
|
Pages: 1 Prev: scrolledtext download location Next: Sharing a program I wrote |