[Python-Dev] Building a Faster Python
Raymond Hettinger
raymond.hettinger at gmail.com
Mon Jul 22 03:04:16 CEST 2013
On Jul 21, 2013, at 5:32 PM, Ned Deily <nad at acm.org> wrote:
> In article <252C50D8-C23D-438D-BAE1-B22E0D65A21A at gmail.com>,
> Raymond Hettinger <raymond.hettinger at gmail.com> wrote:
>> Our current Mac OS X builds use GCC-4.2.
>>
>> On Python2.7, I ran a comparison of gcc-4.2.1 builds
>> versus gcc-4.8.1 and found that the latter makes a much
>> faster Python. PyBench2.0 shows the total running time
>> dropping from 5653ms to 4571ms. The code is uniformly
>> better in just about every category.
>
> Interesting. A note about compilers: it looks like the benchmark used
> the Apple gcc4.2-frontend / LLVM-backend hybrid compiler that is shipped
> with Xcode 4. We don't use that compiler for building any OS X binary
> installers, in fact, we blacklist it for Python 3.3+ because we couldn't
> get it to produce a working 3.3 interpreter:
The results aren't much different using the build published on python.org.
<insert some joke about an Apple-to-Apple comparsion ;-) >
Using a fresh OS X install from our website, PyBench clocks in at 5376ms
Raymond
---------------------------
-------------------------------------------------------------------------------
PYBENCH 2.0
-------------------------------------------------------------------------------
* using CPython 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.time
Calibrating tests. Please wait... done.
Running 10 round(s) of the suite at warp factor 10:
* Round 1 done in 5.459 seconds.
* Round 2 done in 5.510 seconds.
* Round 3 done in 5.476 seconds.
* Round 4 done in 5.473 seconds.
* Round 5 done in 5.497 seconds.
* Round 6 done in 5.533 seconds.
* Round 7 done in 5.520 seconds.
* Round 8 done in 5.518 seconds.
* Round 9 done in 5.515 seconds.
* Round 10 done in 5.515 seconds.
-------------------------------------------------------------------------------
Benchmark: 2013-07-21 17:54:13
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.time
Machine Details:
Platform ID: Darwin-12.4.0-x86_64-i386-64bit
Processor: i386
Python:
Implementation: CPython
Executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Version: 2.7.5
Compiler: GCC 4.2.1 (Apple Inc. build 5666) (dot 3)
Bits: 64bit
Build: May 13 2013 13:18:45 (#v2.7.5:ab05e7dd2788)
Unicode: UCS2
Test minimum average operation overhead
-------------------------------------------------------------------------------
BuiltinFunctionCalls: 108ms 109ms 0.21us 0.166ms
BuiltinMethodLookup: 74ms 77ms 0.07us 0.193ms
CompareFloats: 73ms 73ms 0.06us 0.229ms
CompareFloatsIntegers: 71ms 71ms 0.08us 0.167ms
CompareIntegers: 78ms 78ms 0.04us 0.334ms
CompareInternedStrings: 76ms 77ms 0.05us 0.842ms
CompareLongs: 69ms 70ms 0.07us 0.196ms
CompareStrings: 61ms 61ms 0.06us 0.566ms
CompareUnicode: 66ms 68ms 0.09us 0.431ms
ComplexPythonFunctionCalls: 98ms 101ms 0.51us 0.280ms
ConcatStrings: 166ms 179ms 0.36us 0.324ms
ConcatUnicode: 79ms 81ms 0.27us 0.220ms
CreateInstances: 105ms 107ms 0.96us 0.232ms
CreateNewInstances: 84ms 88ms 1.04us 0.233ms
CreateStringsWithConcat: 95ms 96ms 0.10us 0.552ms
CreateUnicodeWithConcat: 70ms 72ms 0.18us 0.222ms
DictCreation: 79ms 80ms 0.20us 0.221ms
DictWithFloatKeys: 83ms 84ms 0.09us 0.414ms
DictWithIntegerKeys: 87ms 88ms 0.07us 0.552ms
DictWithStringKeys: 65ms 66ms 0.06us 0.552ms
ForLoops: 58ms 58ms 2.34us 0.039ms
IfThenElse: 65ms 66ms 0.05us 0.414ms
ListSlicing: 72ms 89ms 6.38us 0.055ms
NestedForLoops: 79ms 82ms 0.05us 0.014ms
NestedListComprehensions: 94ms 96ms 7.98us 0.056ms
NormalClassAttribute: 81ms 81ms 0.07us 0.280ms
NormalInstanceAttribute: 73ms 75ms 0.06us 0.274ms
PythonFunctionCalls: 85ms 86ms 0.26us 0.166ms
PythonMethodCalls: 100ms 103ms 0.46us 0.086ms
Recursion: 110ms 113ms 2.25us 0.276ms
SecondImport: 104ms 105ms 1.05us 0.112ms
SecondPackageImport: 111ms 111ms 1.11us 0.110ms
SecondSubmoduleImport: 138ms 139ms 1.39us 0.110ms
SimpleComplexArithmetic: 71ms 71ms 0.08us 0.221ms
SimpleDictManipulation: 91ms 92ms 0.08us 0.276ms
SimpleFloatArithmetic: 71ms 72ms 0.05us 0.331ms
SimpleIntFloatArithmetic: 64ms 64ms 0.05us 0.331ms
SimpleIntegerArithmetic: 64ms 64ms 0.05us 0.337ms
SimpleListComprehensions: 81ms 83ms 6.93us 0.056ms
SimpleListManipulation: 61ms 61ms 0.05us 0.359ms
SimpleLongArithmetic: 65ms 66ms 0.10us 0.168ms
SmallLists: 90ms 94ms 0.14us 0.221ms
SmallTuples: 77ms 79ms 0.15us 0.248ms
SpecialClassAttribute: 79ms 79ms 0.07us 0.281ms
SpecialInstanceAttribute: 96ms 98ms 0.08us 0.281ms
StringMappings: 435ms 436ms 1.73us 0.291ms
StringPredicates: 142ms 143ms 0.20us 1.499ms
StringSlicing: 106ms 114ms 0.20us 0.466ms
TryExcept: 68ms 68ms 0.03us 0.414ms
TryFinally: 72ms 73ms 0.46us 0.221ms
TryRaiseExcept: 77ms 78ms 1.23us 0.221ms
TupleSlicing: 90ms 96ms 0.37us 0.036ms
UnicodeMappings: 100ms 101ms 2.79us 0.402ms
UnicodePredicates: 77ms 78ms 0.15us 1.820ms
UnicodeProperties: 95ms 96ms 0.24us 1.503ms
UnicodeSlicing: 91ms 98ms 0.20us 0.412ms
WithFinally: 98ms 100ms 0.62us 0.230ms
WithRaiseExcept: 159ms 163ms 2.04us 0.282ms
-------------------------------------------------------------------------------
Totals: 5376ms 5502ms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130721/04ecd17d/attachment-0001.html>
More information about the Python-Dev
mailing list