Re: speed of python vs matlab.

2006-12-14 Thread greg
Chao wrote: > I did some search, in previous discussion, people has compared > python/numpy vs matlab, > but it is actually comparison between numpy(which is implemented in c) > vs matlab. Yes, matlab is operating on whole arrays at a time, like numpy. So it's not surprising that they have compar

Re: speed of python vs matlab.

2006-12-14 Thread Robert Kern
Chao wrote: > While trying this another question comes up, > psyco seems to be able to optimize built-in functions & user's code, if > I call a function from an external library, it seems doesn't help. > A simple thing is I placed a = numpy.sin(a) in the loop rather than a = > a+1, in this case, >

Re: speed of python vs matlab.

2006-12-14 Thread Chao
Thank you guys for your interest, I tried two things 1) put code into a function 2) use psyco. 1) by putting them into a function, there is a significant improvement, around 30% the running time will be around 0.3sec 2) by using psyco, it really does a great job, the running time is around 0.045

Re: speed of python vs matlab.

2006-12-14 Thread bearophileHUGS
Chao, you can also try Psyco, applied on functions, and when necessary using its metaclass too. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: speed of python vs matlab.

2006-12-14 Thread Roberto Bonvallet
Chao wrote: > My Bad, the time used by python is 0.46~0.49 sec, > I tried xrange, but it doesn't make things better. Actually it does: it doesn't waste time and space to create a big list. -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list

Re: speed of python vs matlab.

2006-12-14 Thread Christophe
Chao a écrit : > My Bad, the time used by python is 0.46~0.49 sec, > I tried xrange, but it doesn't make things better. > > import time > tic = time.time() > a = 1.0 > > array = range(1000) > > for i in array: > for j in array: > a = a + 0.1 > > toc = time.time() > print toc-tic,' ha

Re: speed of python vs matlab.

2006-12-13 Thread Jonathan Curran
On Wednesday 13 December 2006 18:07, Chao wrote: > I've been trying to develop some numerical codes with python, however > got disappointed. > > A very simple test, > > a = 1.0 > > for i in range(1000): > for j in range(1000): >a = a+1 > > unfortunately, it took 4.5 seconds to fini

Re: speed of python vs matlab.

2006-12-13 Thread Chao
My Bad, the time used by python is 0.46~0.49 sec, I tried xrange, but it doesn't make things better. import time tic = time.time() a = 1.0 array = range(1000) for i in array: for j in array: a = a + 0.1 toc = time.time() print toc-tic,' has elapsed' used by matlab is 0.012sec tic

Re: speed of python vs matlab.

2006-12-13 Thread Andrew Sackville-West
On Wed, Dec 13, 2006 at 04:07:20PM -0800, Chao wrote: > I've been trying to develop some numerical codes with python, however > got disappointed. > > A very simple test, > > a = 1.0 > > for i in range(1000): > for j in range(1000): >a = a+1 > > unfortunately, it took 4.5 second

Re: speed of python vs matlab.

2006-12-13 Thread Gabriel Genellina
At Wednesday 13/12/2006 21:07, Chao wrote: I've been trying to develop some numerical codes with python, however got disappointed. A very simple test, a = 1.0 for i in range(1000): for j in range(1000): a = a+1 unfortunately, it took 4.5 seconds to finish(my machines is fine.

Re: speed of python vs matlab.

2006-12-13 Thread Aidan Steele
On 13 Dec 2006 16:07:20 -0800, Chao <[EMAIL PROTECTED]> wrote: I've been trying to develop some numerical codes with python, however got disappointed. A very simple test, a = 1.0 for i in range(1000): for j in range(1000): a = a+1 unfortunately, it took 4.5 seconds to finish(