Re: str.count is slow

2006-02-27 Thread Terry Reedy
"Ben Cartwright" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Your evidence points to some unoptimized code in the underlying C > implementation of Python. As such, this should probably go to the > python-dev list (http://mail.python.org/mailman/listinfo/python-dev). > > The pro

Re: str.count is slow

2006-02-27 Thread Fredrik Lundh
Ben Cartwright wrote: > > On my machine, the output is: > > > > str: 0.29365715475 > > array: 0.448095498171 > > unicode: 0.0243757237303 > This tactic typically avoids most (sometimes all) of the calls to > memcmp. Other string search functions, including unicode.count, > unicode.index, a

Re: str.count is slow

2006-02-27 Thread Ben Cartwright
[EMAIL PROTECTED] wrote: > It seems to me that str.count is awfully slow. Is there some reason > for this? > Evidence: > > str.count time test > import string > import time > import array > > s = string.printable * int(1e5) # 10**7 character string > a = array.array('c', s) > u =