[Numpy-discussion] slow numpy.clip ?

David Cournapeau david at ar.media.kyoto-u.ac.jp
Mon Dec 18 04:09:52 CST 2006


Stefan van der Walt wrote:
> On Mon, Dec 18, 2006 at 05:45:09PM +0900, David Cournapeau wrote:
>> Yes, I of course mistyped the < and the copy. But the function is still 
>> moderately faster on my workstation:
>>
>>   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
>>         1    0.003    0.003    3.944    3.944 slowclip.py:10(bench_clip)
>>         1    0.011    0.011    2.001    2.001 slowclip.py:16(clip1_bench)
>>        10    1.990    0.199    1.990    0.199 
>> /home/david/local/lib/python2.4/site-packages/numpy/core/fromnumeric.py:372(clip)
>>         1    1.682    1.682    1.682    1.682 slowclip.py:19(clip2_bench)
>>         1    0.258    0.258    0.258    0.258 
>> slowclip.py:6(generate_data_2d)
>>         0    0.000             0.000          profile:0(profiler)
>
> Did you try swapping the order of execution (i.e. clip1 second)?
Yes, I tried different orders, etc... and it showed the same pattern. 
The thing is, this kind of thing is highly CPU dependent in my 
experience; I don't have the time right now to update numpy.scipy on my 
laptop, but it happens that profiles results are quite different between 
my workstation (P4 xeon) and my laptop (pentium m).

anyway, contrary to what I thought first, the real problem is the copy, 
so this is where I should investigate in matplotlib case,

David


More information about the Numpy-discussion mailing list