On 14/07/2010 23:32, Eric Firing wrote:
> On 07/14/2010 11:41 AM, Stephen Evans wrote:
>    
>> Hi,
>>
>> While testing Psyco V2 to see if it would offer any speed improvements I
>> tried it with some applications using matplotlib. Exceptions were raised
>> that were easily resolved by replacing calls to min() and max() with
>> their numpy equivalents numpy.amin() and numpy.amax() in the matplotlib
>> code.
>>
>> Simply demonstrated by inserting at the beginning of, say, matplotlib's
>> examples/api/barchart_demo.py :
>>
>> import psyco
>> psyco.full()
>>
>> which caused:
>>
>> Traceback (most recent call last):
>>      File "barchart_demo.py", line 29, in<module>
>>        ax.set_xticks(ind+width)
>>      File "c:\python26\lib\site-packages\matplotlib\axes.py", line 2064,
>> in set_xticks
>>        return self.xaxis.set_ticks(ticks, minor=minor)
>>      File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1154,
>> in set_ticks
>>        self.set_view_interval(min(ticks), max(ticks))
>>      File "c:\python26\lib\site-packages\psyco\builtin.py", line 75, in min
>>        return _min(*args)
>>      File "c:\python26\lib\site-packages\psyco\builtin.py", line 34, in _min
>>        if not iterable:
>> ValueError: The truth value of an array with more than one element is
>> ambiguous. Use a.any() or a.all()
>>
>>
>> software used:
>>
>> Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit
>> (Intel)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>>    >>>   import psyco
>>    >>>   psyco.version_info
>> (2, 0, 0, 'final', 0)
>>    >>>   import numpy
>>    >>>   numpy.version.version
>> '1.4.1'
>>    >>>   import matplotlib
>>    >>>   matplotlib.__version__
>> '0.99.3'
>>
>>
>> Psyco V2 is available from: http://codespeak.net/svn/psyco/v2/dist/
>>
>> Should numpy.min()/numpy.amin() be used on array like objects within
>> matplotlib, or is min() adequate ? Ditto max().
>>      
> When short sequences are involved, min() is much faster than amin(). If
> min() is called only a few times per plot in such cases, using the
> slower function would cause a negligible slowdown.  I'm reluctant to
> change mpl to work around a bug in psyco, though.
>
> When you did make the substitution and do the test, was there a big speedup?
>
> Eric
>    

For a quick check of any speedup I timed some runs on two plots using 
one of my applications with real world data. 4 runs, average of last 3, 
with some meaningless precision:

a) one subplot of 44000 points
b) two subplots of 1.4M points each

using freshly installed matplotlib 1.0

a) 2.97 seconds
b) 37.85

with psyco and changing min() max() to numpy.amin() numpy.amax() where 
appropriate in matplotlib

a) 3.05
b) 27.48

without psyco, but with the changes above

a) 2.96
b) 37.52

Not a rigorous test, but psyco causes a definite speedup in the larger 
plot. Whether this applies throughout matplotlib on all platforms is 
another matter. Hopefully anyone who is using psyco with 
numpy/matplotlib should be able to patch matplotlib themselves where 
required. If it ain't broke, don't fix it.

Stephen

>> Stephen Evans
>>
>> (Out of interest I came across numpy ticket #1286 while looking for this
>> issue.)
>>
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Sprint
>> What will you do first with EVO, the first 4G phone?
>> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>      
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>    


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to