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,' has elapsed'
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
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
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
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,
psyco
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
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
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
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
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
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
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 finish(my
12 matches
Mail list logo