suppose i a have a multiplicative expression with lots of multiplicands (small expressions)
expression = a*b*c*d*....*w
where for example c is (x-1), d is (y**2-16), k is (xy-60)….. x,y are numbers
and i know that c,d,k,j maybe zero
Does the order i write the expression matters for faster evaluation?
Is it better to write cdkj….*w or python will evaluate all expression no matter the order i write?
Python v2.6.5 does not check for zero values.
Update: I tested Baldur‘s expressions, and Python can and will optimize code that involve constant expressions. The weird is that
test6isn’t optimized.In brief, if the expression includes variables, the order doesn’t matter. Everything will be evaluated.