list comprehension question
rusi
rustompmody at gmail.com
Wed Oct 17 10:50:10 EDT 2012
On Oct 17, 7:37 pm, Dave Angel <d... at davea.name> wrote:
> And I'd wager all the improvement is in the inner loop, the dot() function.
Sorry -- red herring!
Changing
def mm1(a,b): return [[sum(x*y for x,y in zip(ra,rb)) for rb in
zip(*b)] for ra in a]
to
def mm1(a,b): return [[sum([x*y for x,y in zip(ra,rb)]) for rb in
zip(*b)] for ra in a]
makes the speed diff vanish
More information about the Python-list
mailing list