Hi,
Here is the matlab code:
function [z]=bench1(n)
for i=1:n,
for j=1:1000,
z=log(j);
z1=log(j+1);
z2=log(j+2);
z3=log(j+3);
z4=log(j+4);
z5=log(j+5);
z6=log(j+6);
z7=log(j+7);
z8=log(j+8);
z9=log(j+9);
end
end
z = z9;
I am not familiar with python, so I just simply try to reproduce the same
code in python.
If you think that my python script is not efficient, could you tell me how
to make it more efficient?
Thanks
Frank
From: Roberto Bonvallet <[EMAIL PROTECTED]>
To: python-list@python.org
Subject: Re: Speed of Python
Date: Fri, 07 Sep 2007 17:19:02 -0000
On Sep 7, 12:42 pm, "wang frank" <[EMAIL PROTECTED]> wrote:
> Here is the bench1.py:
> import math
> def bench1(n):
> for i in range(n):
> for j in range(1000):
> m=j+1
> z=math.log(m)
> z1=math.log(m+1)
> z2=math.log(m+2)
> z3=math.log(m+3)
> z4=math.log(m+4)
> z5=math.log(m+5)
> z6=math.log(m+6)
> z7=math.log(m+7)
> z8=math.log(m+8)
> z9=math.log(m+9)
> return z9
>
> Is my conclusion correct that Python is slower than matlab?
Show us your Matlab code in order to see if both are equivalent.
Your Python code creates n lists of 1000 elements, so you're not
actually
measuring only the numeric computations.
Cheers,
--
Roberto Bonvallet
--
http://mail.python.org/mailman/listinfo/python-list
_________________________________________________________________
メッセンジャー用アイコンに大人気オンラインゲームの萌えなキャラが登場!
http://messenger.live.jp/
--
http://mail.python.org/mailman/listinfo/python-list