[Numpy-discussion] product of arrays of different lengths

Alan G Isaac aisaac@american....
Mon Sep 15 12:48:54 CDT 2008


SimonPalmer wrote:
> what is the overhead associated with importing a new module (whichever 
> includes izip)? 
> I am wondering whether it is actually more efficient for me to put my 
> aesthetics aside and stick with my ugly but efficient loop 

If you do not want to use izip, you can still avoid array
creation by using ``dot``::

     max_idx = min(len(A), len(B))
     np.dot(A[:max_idx], B[:max_idx])

Cheers,
Alan Isaac



More information about the Numpy-discussion mailing list