[EMAIL PROTECTED] wrote: > I hope I am not being too ignorant :p but here goes... my boss has > written a bit of python code and asked me to speed it up for him... > I've reduced the run time from around 20 minutes to 13 (not bad I think > ;) to speed it up further I asked him to replace a loop like this:- > > > index = 0 > > for element in a: > av = a[index] > bv = b[index] > cv = c[index] > dv = d[index] > avbv = (av-bv) * (av-bv) > diff = cv - dv > e.append(diff - avbv) > index = index + 1
For /real/ speed-ups use a numerical library, e. g. # untested from numarray import array a = array(a) b = array(b) c = array(c) d = array(d) e = (c-d) - (a-b)*(a-b) Peter -- http://mail.python.org/mailman/listinfo/python-list