[Python-Dev] memcmp performance

Stefan Behnel stefan_ml at behnel.de
Fri Oct 21 20:57:45 CEST 2011


Richard Saunders, 21.10.2011 20:23:
> As long as the two strings are the same unicode "kind", you can use a
> memcmp to compare. In that case, I would almost argue some memcmp
> optimization is even more important: unicode strings are potentially 2
> to 4 times larger, so the amount of time spent in memcmp may be more
> (i.e., I am still rooting for -fno-builtin-memcmp on the compile lines).

I would argue that the pure ASCII (1 byte per character) case is even more 
important than the other cases, and it suffers from the "1 byte per 
comparison" problem you noted. That's why you got the 2x speed-up for your 
quick test.

Stefan



More information about the Python-Dev mailing list