In article
bdb112 wrote:
>First a trap for new players, then a question to developers
>
>Code accelerated by numpy can be slowed down by a large factor is you
>neglect to import numpy.sum .
>
>from timeit import Timer
>frag = 'x=sum(linspace(0,1,1000))'
>Timer(frag ,setup='from numpy import lins
On Friday, July 1 at 19:17 (-0700), bdb112 said:
> Question:
> Can I replace the builtin sum function globally for test purposes so
> that my large set of codes uses the replacement?
>
> The replacement would simply issue warnings.warn() if it detected an
> ndarray argument, then call the origi
First a trap for new players, then a question to developers
Code accelerated by numpy can be slowed down by a large factor is you
neglect to import numpy.sum .
from timeit import Timer
frag = 'x=sum(linspace(0,1,1000))'
Timer(frag ,setup='from numpy import linspace').timeit(1000)
# 0.6 sec
Timer(