[Python-Dev] -O2 faster than -O3?

Neil Toronto ntoronto at cs.byu.edu
Fri Nov 30 21:02:07 CET 2007


On both of my systems, using -O2 reduces execution time in pystone by 9% 
and in pybench by 8%. It's function inlining: "-O3 
-fno-inline-functions" works just as well as "-O2". Removing "-g" has 
little effect on the result.

Systems:
  - AMD Athlon 64 X2 Dual Core 4600+, 512 KB cache (desktop)
  - Intel T2300 Dual Core 1.66GHz, 512 KB cache (laptop)

Both are Ubuntu 7.04, GCC 4.1.2.

Does anybody else see this?

It may be GCC being stupid (which has happened before) or not enough 
cache on my systems (definitely possible). If it's not one of those, I'd 
say it's because CPython core functions are already very large, and 
almost everything that ought to be inlined is already a macro.

Pybench comparison for the Athlon:

http://spreadsheets.google.com/ccc?key=pHIJrYc_pnIXCwJvDvU9gfQ&hl=en_US

Neil


More information about the Python-Dev mailing list