Changes between Version 6 and Version 7 of PossibleOptimizationAreas

Show
Ignore:
Timestamp:
02/27/06 20:54:17 (7 years ago)
Author:
sasha
Comment:

moved ndarray.fill discussion to a separate page

Legend:

Unmodified
Added
Removed
Modified
  • PossibleOptimizationAreas

    v6 v7  
    66 * Default (digits=0) case of around is 10x slower than {{{(x+0.5).astype(int).astype(float)}}}. Resolved: changeset:2151 implements fast rint function and adds a round method to ndarray that is about as fast for digits=0 case. 
    77  
    8  * As of changeset:2173 {{{x.fill(1)}}} is 2x slower than {{{x += 1}}}.  One should be able to set memory to a constant value faster than autoincrement. 
    9  
    10 {{{ 
    11 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'b')" "x.fill(1)" 
    12 10000 loops, best of 3: 69.5 usec per loop 
    13 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'h')" "x.fill(1)" 
    14 10000 loops, best of 3: 66.1 usec per loop 
    15 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'i')" "x.fill(1)" 
    16 10000 loops, best of 3: 66.3 usec per loop 
    17 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'d')" "x.fill(1)" 
    18 10000 loops, best of 3: 73.2 usec per loop 
    19 }}} 
    20 {{{ 
    21 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'b')" "x += 1" 
    22 10000 loops, best of 3: 58 usec per loop 
    23 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'h')" "x += 1" 
    24 10000 loops, best of 3: 33.7 usec per loop 
    25 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'i')" "x += 1" 
    26 10000 loops, best of 3: 33.6 usec per loop 
    27 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'d')" "x += 1" 
    28 10000 loops, best of 3: 36.9 usec per loop 
    29 }}} 
    30 The [attachment:fast-fill-patch.txt attached patch] results in the following timings: 
    31 {{{ 
    32 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'b')" "x.fill(1)" 
    33 100000 loops, best of 3: 4.55 usec per loop 
    34 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'h')" "x.fill(1)" 
    35 100000 loops, best of 3: 12 usec per loop 
    36 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'i')" "x.fill(1)" 
    37 100000 loops, best of 3: 12.4 usec per loop 
    38 > python -m timeit -s "from numpy import zeros; x = zeros(10000,'d')" "x.fill(1)" 
    39 100000 loops, best of 3: 13 usec per loop 
    40 }}} 
    41 Note the more than 10x improvement in the 'b' case.   
     8 * As of changeset:2173 {{{x.fill(1)}}} is 2x slower than {{{x += 1}}}.  One should be able to set memory to a constant value faster than autoincrement. [wiki:PossibleOptimizationAreas/FillDiscussion Discussion].