[SciPy-user] evaluating a really long, multiline expression

Ryan Krauss ryanlists at gmail.com
Wed Nov 23 15:37:23 CST 2005

I have a really long symbolic expression that is being generated by
Maxima and output to a text file.  I need to turn this into a python
function that I will use in optimize.newton and optimize.fmin.  It is
almost 9000 lines and the first 10 lines look like this :

bv3 = (s^5*(abeam^2*betabeam^2*c3beam

Aside from replacing the ^ with ** and needing to get rid of the
un-python-ish spacing at the front, any thoughts on how to make python
evalute this expression quickly (assuming that all the variables are
assigned numeric values by the function).  I am a little nervous that
such a long expression will take a really long time to evaluate.  But
I haven't tried it yet.  Any thoughts on parsing this thing?  am I
better off leaving it a 9000 line statement or making one really long
line (I think about 300,000 characters)?  Is there any speed trade off
with multiline commands?


More information about the SciPy-user mailing list