Re: list comprehension question

Discussion in 'Python' started by Oscar Benjamin, Oct 17, 2012.

  1. On 17 October 2012 06:09, Dwight Hutto <> wrote:
    > On Wed, Oct 17, 2012 at 12:43 AM, Kevin Anthony
    > <> 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.
    Oscar Benjamin, Oct 17, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Elston

    List Comprehension question

    Mark Elston, Dec 11, 2003, in forum: Python
    Replies:
    1
    Views:
    311
    Francis Avila
    Dec 11, 2003
  2. Eelco Hoekema

    [Newby question] List comprehension

    Eelco Hoekema, Aug 6, 2004, in forum: Python
    Replies:
    7
    Views:
    272
    Eelco Hoekema
    Aug 6, 2004
  3. Shane Geiger
    Replies:
    4
    Views:
    373
    bullockbefriending bard
    Mar 25, 2007
  4. Debajit Adhikary
    Replies:
    17
    Views:
    671
    Debajit Adhikary
    Oct 18, 2007
  5. Vedran Furac(
    Replies:
    4
    Views:
    316
    Marc 'BlackJack' Rintsch
    Dec 19, 2008
Loading...

Share This Page