[Numpy-discussion] which one is best?

Alan G Isaac aisaac at american.edu
Fri Sep 19 10:24:14 EDT 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