[SciPy-user] Accelerating the calculation of a function

Simon Burton simon at arrowtheory.com
Sun Aug 6 19:57:56 CDT 2006


On Sun, 6 Aug 2006 22:40:39 +0200
Gael Varoquaux <gael.varoquaux at normalesup.org> wrote:

>     Hi list,
> 
> I am integrating an ODE. I thus have a complicated function that
> I call a lot of times. What limits my execution times (currently too
> high) is the call to this function, which happens a great number of
> times. I therefore need to speed this up.
> 
> 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]) ).
> 
> How can I speed this up without rendering my function unreadable ? Is
> there a compiler (Just in time, maybe) that could speed this up ? Is
> psyco of any use ?

My tool of choice has been pyrex.
(Note that it cannot handle list comprehensions.)
Psyco does not understand numpy arrays (read: slow), but it
does understand (ie. optimize for) the python array type.

> 
> Is their a way to inline my functions (I would like to keep them as
> functions for the sake of readability) ?

Yes, I hear you. I recently found this bytecodehacks/psyco post:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/eab35852b7f1e98c/3174613b8b02f5d9

Simon.




-- 
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 2 6249 6940
http://arrowtheory.com 


More information about the SciPy-user mailing list