[Python-Dev] memcmp performance
stefan_ml at behnel.de
Fri Oct 21 08:24:44 CEST 2011
Antoine Pitrou, 20.10.2011 23:08:
>> I have been doing some performance experiments with memcmp, and I was
>> surprised that memcmp wasn't faster than it was in Python. I did a whole,
>> long analysis and came up with some very simple results.
> Thanks for the analysis. Non-bugfix work now happens on Python 3, where
> the str type is Python 2's unicode type. Your recommendations would
> have to be revisited under that light.
Well, Py3 is quite a bit different now that PEP393 is in. It appears to use
memcmp() or strcmp() a lot less than before, but I think unicode_compare()
should actually receive an optimisation to use a fast memcmp() if both
string kinds are equal, at least when their character unit size is less
than 4 (i.e. especially for ASCII strings). Funny enough, tailmatch() has
such an optimisation.
More information about the Python-Dev