Message156578
PyFloat_FromString() is very restrictive. In our case, for example, the floats in question don't come from text files.
I'm adding a new file with changes suggested by Antoine. only 0.0 and 1.0 are interned. It turns out that the "int" test is expensive, and special casing it to check for '0.0' and '1.0' with direct float comparison makes the performance hit go away. Here are the figures:
D:\pydev\hg\cpython2>pcbuild10\python.exe Tools\pybench\pybench.py -s interned8 -c normal
-------------------------------------------------------------------------------
PYBENCH 2.1
-------------------------------------------------------------------------------
* using CPython 3.3.0a1+ (default, Mar 22 2012, 15:39:50) [MSC v.1600 32 bit (Intel)]
* disabled garbage collection
* system check interval set to maximum: 2147483647
* using timer: time.clock
-------------------------------------------------------------------------------
Benchmark: interned8
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.clock
Machine Details:
Platform ID: Windows-7-6.1.7601-SP1
Processor: Intel64 Family 6 Model 26 Stepping 5, GenuineIntel
Python:
Implementation: CPython
Executable: D:\pydev\hg\cpython2\pcbuild10\python.exe
Version: 3.3.0a1+
Compiler: MSC v.1600 32 bit (Intel)
Bits: 32bit
Build: Mar 22 2012 15:39:50 (#default)
Unicode: UCS4
-------------------------------------------------------------------------------
Comparing with: normal
-------------------------------------------------------------------------------
Rounds: 10
Warp: 10
Timer: time.clock
Machine Details:
Platform ID: Windows-7-6.1.7601-SP1
Processor: Intel64 Family 6 Model 26 Stepping 5, GenuineIntel
Python:
Implementation: CPython
Executable: D:\pydev\hg\cpython2\pcbuild10\python.exe
Version: 3.3.0a1+
Compiler: MSC v.1600 32 bit (Intel)
Bits: 32bit
Build: Mar 22 2012 13:53:45 (#default)
Unicode: UCS4
Test minimum run-time average run-time
this other diff this other diff
-------------------------------------------------------------------------------
BuiltinFunctionCalls: 59ms 59ms -0.7% 60ms 60ms -0.3%
BuiltinMethodLookup: 40ms 40ms -0.2% 40ms 40ms -0.2%
CompareFloats: 47ms 46ms +2.3% 47ms 46ms +2.3%
CompareFloatsIntegers: 125ms 126ms -0.8% 129ms 131ms -2.0%
CompareIntegers: 76ms 76ms -0.2% 76ms 76ms -0.3%
CompareInternedStrings: 60ms 60ms -0.0% 61ms 61ms +0.2%
CompareLongs: 44ms 44ms -0.4% 44ms 44ms -0.4%
CompareStrings: 59ms 58ms +2.1% 59ms 58ms +1.8%
ComplexPythonFunctionCalls: 59ms 60ms -1.7% 60ms 61ms -2.5%
ConcatStrings: 49ms 55ms -10.7% 49ms 55ms -10.6%
CreateInstances: 67ms 66ms +1.1% 68ms 68ms -0.1%
CreateNewInstances: 50ms 50ms +1.3% 51ms 50ms +0.4%
CreateStringsWithConcat: 70ms 71ms -1.3% 70ms 72ms -1.7%
DictCreation: 45ms 46ms -1.7% 46ms 46ms -1.5%
DictWithFloatKeys: 81ms 84ms -2.8% 81ms 84ms -2.7%
DictWithIntegerKeys: 52ms 55ms -5.4% 52ms 55ms -5.1%
DictWithStringKeys: 47ms 51ms -6.6% 48ms 51ms -6.6%
ForLoops: 42ms 42ms +0.2% 42ms 42ms +0.2%
IfThenElse: 63ms 59ms +5.5% 63ms 59ms +5.6%
ListSlicing: 39ms 39ms +0.0% 39ms 39ms -0.4%
NestedForLoops: 67ms 67ms -0.2% 68ms 68ms +0.0%
NestedListComprehensions: 63ms 62ms +1.2% 64ms 63ms +1.2%
NormalClassAttribute: 102ms 100ms +1.3% 102ms 101ms +1.4%
NormalInstanceAttribute: 62ms 62ms +0.2% 63ms 63ms +0.2%
PythonFunctionCalls: 60ms 60ms +0.8% 61ms 60ms +1.3%
PythonMethodCalls: 74ms 74ms -0.0% 74ms 74ms -0.3%
Recursion: 103ms 102ms +1.4% 104ms 102ms +1.3%
SecondImport: 109ms 109ms -0.4% 110ms 110ms -0.6%
SecondPackageImport: 111ms 112ms -0.6% 113ms 113ms +0.2%
SecondSubmoduleImport: 154ms 153ms +0.7% 155ms 155ms -0.2%
SimpleComplexArithmetic: 56ms 54ms +3.7% 57ms 56ms +1.9%
SimpleDictManipulation: 94ms 93ms +0.3% 94ms 94ms -0.2%
SimpleFloatArithmetic: 45ms 44ms +3.2% 45ms 45ms +1.7%
SimpleIntFloatArithmetic: 57ms 56ms +1.8% 57ms 57ms +0.1%
SimpleIntegerArithmetic: 56ms 56ms +1.2% 57ms 56ms +1.0%
SimpleListComprehensions: 53ms 52ms +1.8% 54ms 53ms +2.4%
SimpleListManipulation: 49ms 53ms -8.0% 50ms 53ms -6.7%
SimpleLongArithmetic: 41ms 40ms +1.6% 41ms 41ms +0.1%
SmallLists: 66ms 68ms -2.8% 67ms 68ms -2.5%
SmallTuples: 76ms 72ms +5.5% 76ms 72ms +5.8%
SpecialClassAttribute: 144ms 140ms +2.8% 145ms 142ms +2.1%
SpecialInstanceAttribute: 64ms 64ms +0.7% 65ms 64ms +1.1%
StringMappings: 126ms 132ms -4.2% 127ms 132ms -4.0%
StringPredicates: 71ms 70ms +2.3% 72ms 70ms +2.5%
StringSlicing: 66ms 67ms -0.6% 67ms 67ms -1.1%
TryExcept: 44ms 43ms +1.5% 44ms 44ms +0.7%
TryFinally: 49ms 53ms -7.4% 49ms 54ms -8.1%
TryRaiseExcept: 24ms 22ms +8.6% 25ms 23ms +8.9%
TupleSlicing: 61ms 61ms -0.7% 61ms 62ms -0.5%
WithFinally: 65ms 65ms -0.3% 65ms 65ms -0.0%
WithRaiseExcept: 62ms 62ms -0.4% 62ms 63ms -0.6%
-------------------------------------------------------------------------------
Totals: 3448ms 3454ms -0.2% 3474ms 3487ms -0.4%
(this=interned8, other=normal)
D:\pydev\hg\cpython2> |
|
Date |
User |
Action |
Args |
2012-03-22 15:49:37 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson, mark.dickinson, pitrou, michael.foord, serhiy.storchaka |
2012-03-22 15:49:36 | kristjan.jonsson | set | messageid: <1332431376.48.0.723378079453.issue14381@psf.upfronthosting.co.za> |
2012-03-22 15:49:35 | kristjan.jonsson | link | issue14381 messages |
2012-03-22 15:49:34 | kristjan.jonsson | create | |
|