str.count is slow
Fredrik Lundh
fredrik at pythonware.com
Mon Feb 27 19:04:05 EST 2006
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, and str.index, use this tactic, which is why you see
> unicode.count performing better than str.count.
it's about time that someone sat down and merged the string and unicode
implementations into a single "stringlib" code base (see the SRE sources for
an efficient way to do this in plain C).
moving to (basic) C++ might also be a good idea (in 3.0, perhaps). is any-
one still stuck with pure C89 these days ?
</F>
More information about the Python-list
mailing list