Iteration over two sequences

Steven Bethard steven.bethard at
Wed Jan 12 13:49:14 EST 2005

Henrik Holm wrote:
> John Lenton <jlenton at> wrote:
>>>def dotproduct(a, b):
>>>   psum = 0
>>>   for i in range(len(a)):
>>>       psum += a[i]*b[i]
>>>   return psum
>>for this particular example, the most pythonic way is to do nothing at
>>all, or, if you must call it dotproduct,
>>>>>from Numeric import dot as dotproduct
> Downloading, installing, and getting to know numerical modules for
> Python is mext on my list :).  However, I was under the impression that
> Numarray is preferred to Numeric -- is that correct?  Are these two
> competing packages?  (Hopefully this is not flame war bait...)

Numarray is the replacement for Numeric.  Some people are still using 
Numeric for a variety of reasons, e.g. they use a package that has not 
been updated to use numarray, they can't afford the performance penalty 
that numarray has for small arrays, etc.


More information about the Python-list mailing list