[Numpy-discussion] which one is best?

Alan G Isaac aisaac@american....
Fri Sep 19 09:24:14 CDT 2008

Given your restrictions I'd probably pick
[ x * y for x,y in izip(a,b) ]
(note the change to ``izip``).
But maybe you do not really need lists at all...

You can also do
c = (array(a)*array(b)).tolist()
which is nice and explicit but
builds 3 unnecessary arrays.

Alan Isaac

More information about the Numpy-discussion mailing list