I hope I am not being too ignorant :p but here goes... my boss has
written a bit of python code and asked me to speed it up for him...
I've reduced the run time from around 20 minutes to 13 (not bad I think
;) to speed it up further I asked him to replace a loop like this:-
index = 0
for
itertools.izip is usually faster than zip. You can try that.
--
http://mail.python.org/mailman/listinfo/python-list
Rune Strand wrote:
itertools.izip is usually faster than zip. You can try that.
Thanks very much
timing for itertools.izip
for av, bv, cv, dv in itertools.izip(a, b, c, d):
avbv = (av-bv) * (av - bv)
diff = cv - dv
e.append(diff - avbv)
on a 4 million element aray:
slice:
[EMAIL PROTECTED] wrote:
## just for a laugh my own zip function
## the joke is it runs faster than built in zip ??
since it doesn't do the same thing, it's not a very good joke.
def myzip(*args):
index = 0
for elem in args[0]:
zipper = []
for arg in args:
On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote:
I hope I am not being too ignorant :p but here goes... my boss has
written a bit of python code and asked me to speed it up for him...
I've reduced the run time from around 20 minutes to 13 (not bad I think
;) to speed it up further
so fastest overall
you may experience speed-ups by using
from itertools import izip
and just use izip() instead to avoid the module namespace lookup. The
same applies for the list.append() methods. If you're appending some
million times
a_list = []
a_list_append = a_list.append
Steven D'Aprano wrote:
On Tue, 04 Jul 2006 07:18:29 -0700, [EMAIL PROTECTED] wrote:
I hope I am not being too ignorant :p but here goes... my boss has
written a bit of python code and asked me to speed it up for him...
I've reduced the run time from around 20 minutes to 13 (not bad I think
Fredrik Lundh wrote:
[EMAIL PROTECTED] wrote:
## just for a laugh my own zip function
## the joke is it runs faster than built in zip ??
since it doesn't do the same thing, it's not a very good joke.
def myzip(*args):
index = 0
for elem in args[0]:
zipper = []
[EMAIL PROTECTED]:
Using Python you can do:
# Data:
l_a = [1.1, 1.2]
l_b = [2.1, 2.2]
l_c = [3.1, 3.2]
l_d = [5.1, 4.2]
from itertools import izip
l_e = [(c-d) - (a-b)*(a-b) for a,b,c,d in izip(l_a, l_b, l_c, l_d)]
print l_e
With psyco + the standard module array you can probably go quite
[EMAIL PROTECTED] wrote:
I hope I am not being too ignorant :p but here goes... my boss has
written a bit of python code and asked me to speed it up for him...
I've reduced the run time from around 20 minutes to 13 (not bad I think
;) to speed it up further I asked him to replace a loop like
Peter Otten wrote:
from numarray import array
a = array(a)
b = array(b)
c = array(c)
d = array(d)
e = (c-d) - (a-b)*(a-b)
Oops, bearophile has already posted the same idea with better execution...
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] writes:
[...]
(Instead of numarray you can use ScyPy, numerics, etc.)
If your data in on disk you can avoid the list=array conversion, and
load the data from the numerical library itself, this is probably
almost as fast as doing the same thing in C.
Apparently if you're
12 matches
Mail list logo