[SciPy-user] Accelerating the calculation of a function

Steve Schmerler elcorto at gmx.net
Sun Aug 6 23:26:04 EDT 2006


Gael Varoquaux wrote:

> If  it  where a simple function I could use weave.inline or weave.blitz
> but this is a rather complicated function involving a lot of python
> magic that I would be very happy to keep ( things such as :
> sum( [F(k) for k in lasers]) ).

You're most probably doing it already (I just wondered about the list 
comprehension): Can you do numpy.sum(F(lasers)) in your function (that 
is, is 'lasers' a simple array)? Note that numpy.sum (or a.sum()) is 
much faster then the builtin sum() for large arrays. Also use 
numpy.amin(<array>) instead of min() and stuff like that.

HTH
steve

-- 
Random number generation is the art of producing pure gibberish as 
quickly as possible.



More information about the SciPy-User mailing list