Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31546 > unrolled thread

Re: list comprehension question

Started byOscar Benjamin <oscar.j.benjamin@gmail.com>
First post2012-10-17 23:34 +0100
Last post2012-10-17 23:34 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: list comprehension question Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-17 23:34 +0100

#31546 — Re: list comprehension question

FromOscar Benjamin <oscar.j.benjamin@gmail.com>
Date2012-10-17 23:34 +0100
SubjectRe: list comprehension question
Message-ID<mailman.2369.1350513251.27098.python-list@python.org>
On 17 October 2012 06:09, Dwight Hutto <dwightdhutto@gmail.com> wrote:
> On Wed, Oct 17, 2012 at 12:43 AM, Kevin Anthony
> <kevin.s.anthony@gmail.com> wrote:
>> Is it not true that list comprehension is much faster the the for loops?
>>
>> If it is not the correct way of doing this, i appoligize.
>> Like i said, I'm learing list comprehension.
>>
> I thought it was matrix multiplication mixed with list comprehension.
>
> Check this out real quick from the docs for list comprehension, but if
> it's a mixture of matrix multi, and list comp, then reply back.
>
> http://docs.python.org/tutorial/datastructures.html#list-comprehensions

If you're looking for a fast solution then you should follow David's
suggestion and use numpy:

> http://www.scipy.org/FAQ#head-045cba7978d75ec548822222150fa6ad308e325a
>
> www.python-course.eu/matrix_arithmetic.php

The most relevant numpy function is numpy.dot:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html


Oscar

P.S. David, it was a bit fiddly for me to quote your response because
the relevant part was in a post that had no context. Also your name is
listed as Dwight above. That is automatically added by gmail because
of the settings in your own email client. You may need to change your
account settings if you want it to say David when people quote you.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web