Speed of Python
S bastien Boisg rault
Sebastien.Boisgerault at gmail.com
Fri Sep 7 19:02:04 CEST 2007
On Sep 7, 6:42 pm, "wang frank" <f... at hotmail.co.jp> wrote:
Matlab (aka MATrix LABoratory) has been designed with numeric
computations in mind (every object being natively a n-dim
array). If you wish to develop that kind of applications in
Python, consider using the numerical array structure provided
by Numpy. Numpy being mostly written in C, that should speed
up your application ... In this context, additional 3rd party
libs such as Scipy, Matplotlib, PIL, etc. will also be useful.
> While comparing the speed of octave and matlab, I decided to do a similar
> test for python and matlab. The result shows that python is slower than
> matlab by a factor of 5. It is not bad since octave is about 30 time slower
> than matlab.
> Here is the result in matlab:
> Elapsed time is 0.015389 seconds.
> and in Python:>>> t=timeit.Timer("bench1.bench1(10)","import bench1")
> >>> t.repeat(1,1)
> Here is the bench1.py:
> import math
> def bench1(n):
> for i in range(n):
> for j in range(1000):
> return z9
> Is my conclusion correct that Python is slower than matlab? Are there any
> way to speed it up? It seems Python automatically created bench1.pyc. Does
> Python automatically execute the bench1.pyc to speed it up?
> 「地図マガ」特集 残暑を吹きとばせ！ご当地アイスクリームマップが登場http://chizumaga.jp/
More information about the Python-list