[issue17628] str==str: compare the first and last character before calling memcmp()

STINNER Victor report at bugs.python.org
Thu Apr 4 00:10:33 CEST 2013


STINNER Victor added the comment:

benchmark2: Results on a slower computer. Comparing equal strings is much faster with the patch. Example:

equal, 'A', 1000000          |  945 us (*) | 1.25 ms (+32%)

I don't understand why the patch makes the comparaison much slower, since most time is supposed to be spend in memcmp()?

Is it because I starts at the second character to compare strings, instead of the first character? Memory alignment issue?

----------
Added file: http://bugs.python.org/file29672/benchmark2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17628>
_______________________________________


More information about the Python-bugs-list mailing list