[Python-Dev] memcmp performance

Scott Dial scott+python-dev at scottdial.com
Thu Oct 20 23:38:16 CEST 2011


On 10/20/2011 5:08 PM, Antoine Pitrou wrote:
> Have you reported gcc's "outdated optimization" issue to them? Or is it
> already solved in newer gcc versions?

I checked this on gcc 4.6, and it still optimizes memcmp/strcmp into a
"repz cmpsb" instruction on x86. This has been known to be a problem
since at least 2002[1][2]. There are also some alternative
implementations available on their mailing list. It seems the main
objection to removing the optimization was that gcc isn't always
compiling against an optimized libc, so they didn't want to drop the
optimization. Beyond that, I think nobody was willing to put in the
effort to change the optimization itself.

[1] http://gcc.gnu.org/ml/gcc/2002-10/msg01616.html
[2] http://gcc.gnu.org/ml/gcc/2003-04/msg00166.html

-- 
Scott Dial
scott at scottdial.com


More information about the Python-Dev mailing list