Parallel arithmetic?

Lonnie Princehouse finite.automaton at gmail.com
Thu Aug 4 19:07:41 EDT 2005


There are many ways to do this.  None of them avoids looping,
technically, although you can easily avoid the "for" syntax.

-- Simple but wastes some memory
    c = [i-j for i,j in zip(a,b)]

-- Using itertools.izip (python 2.3)
    c = [i-j for i,j in itertools.izip(a,b) ]

-- Generator expression (python 2.4)
    c = ( i-j for i,j in itertools.izip(a,b) )




More information about the Python-list mailing list