Hi,
we are working on a small scientific program that helps us in developing
and testing of new numerical methods for a certain type of biochemical
problems. I spare you the math ;-)
We code our new methods in Python and compare them with the existing
methods. Unfortunately, these existing m
Hi,
thanks a lot for your answers. I learn a lot and I like to sum up your
suggestions and show you the results of the time command on my machine:
Original code by me:
imax = 10
a = 0
for i in xrange(imax):
a = a + 10
print a
=> runs (wall clock time): 1:55.14
Peter Otten suggeste
Peter Otten wrote:
Move it into a function; this turns a and i into local variables.
def f():
imax = 10
a = 0
for i in xrange(imax):
a = a + 10
print a
f()
Wow. It is still slower than Matlab, but your suggestion speeds up the
code by ca 50%.
But I do not under
Hi,
I was comparing the speed of a simple loop program between Matlab and
Python.
My Codes:
$ cat addition.py
imax = 10
a = 0
for i in xrange(imax):
a = a + 10
print a
$ cat addition.m
imax = 1e9;
a = 0;
for i=0:imax-1
a = a + 10;
end
disp(a);
exit;
The results look like this