Iteration over two sequences

Steven Bethard steven.bethard at gmail.com
Wed Jan 12 19:49:14 CET 2005


Henrik Holm wrote:
> John Lenton <jlenton at gmail.com> 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.

Steve



More information about the Python-list mailing list