speed of python vs matlab.

Andrew Sackville-West andrew at farwestbilliards.com
Wed Dec 13 20:02:53 EST 2006


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 seconds to finish(my machines is fine. P4
> 3.0G, 1G RAM, it varies according to machine configuration, but should
> be in the same level)

somethings not right there.

andrew at debian:~$ cat pytimetest.py
a=1.0
for i in range (1000):
    for j in range (1000):
         a=a+1


andrew at debian:~$ time python pytimetest.py

real    0m0.534s
user    0m0.528s
sys     0m0.000s


andrew at debian:~$ cat /proc/cpuinfo  | grep name
model name      : Intel(R) Celeron(R) CPU 2.53GHz

andrew at debian:~$ uname -a
Linux debian 2.6.18-3-686 #1 SMP Mon Dec 4 16:41:14 UTC 2006 i686
GNU/Linux

A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20061213/03b1f6ef/attachment.sig>


More information about the Python-list mailing list