built in zip function speed

mart.franklin at gmail.com mart.franklin at gmail.com
Tue Jul 4 10:59:57 EDT 2006


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:
8.06299996376

built in zip:
36.5169999599

myzip:
12.0320000648

izip:
5.76499986649


so fastest overall




More information about the Python-list mailing list