On Sep 7, 12:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote:
> Is my conclusion correct that Python is slower than matlab? Are there any > way to speed it up? Yes, use Numpy for any non trivial number-crunching task: http://numpy.scipy.org/. Even if you don't, you can speed up the original function by ~25% if you replace range() with xrange() and bind the log function to a local variable: def bench2(n): from math import log for i in xrange(n): for j in xrange(1000): m=j+1 z=log(m) z1=log(m+1) z2=log(m+2) z3=log(m+3) z4=log(m+4) z5=log(m+5) z6=log(m+6) z7=log(m+7) z8=log(m+8) z9=log(m+9) return z9 HTH, George
-- http://mail.python.org/mailman/listinfo/python-list