Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.062 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'subject:skip:c 10': 0.07; 'subject:question': 0.08; 'cc:addr:python-list': 0.10; 'mixture': 0.16; 'numpy': 0.16; 'oct': 0.16; 'settings': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'bit': 0.21; 'back.': 0.22; 'context.': 0.22; 'kevin': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'cc:addr:gmail.com': 0.27; 'cc:2**2': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'subject:list': 0.28; 'post': 0.28; "i'm": 0.29; 'function': 0.30; 'url:python': 0.32; 'suggestion': 0.32; 'docs': 0.33; 'mixed': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'faster': 0.35; 'said,': 0.35; 'doing': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'cc:no real name:2**1': 0.36; 'should': 0.36; 'october': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'header:Received:5': 0.40; 'your': 0.60; 'most': 0.61; 'you.': 0.61; 'real': 0.61; 'p.s.': 0.63; 'reply': 0.66; 'account': 0.67; 'david,': 0.84; 'oscar': 0.84; 'url:reference': 0.84; 'url:tutorial': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=thsF8NUWv9kREuIyX5eB6V0M2YgOUWaH3H2tlnu3l/0=; b=P7cmt64L/2rQeB4O4WUO+N8DRVnWEZGnNXKa0LTXguXrk6e/nrz8dQ6/Ovjaaenxuy xJvMmEgi720QHYgzhgpv0PxuH9JLGsuKsUN7FU0RraC/AkZeiGOxVsXkFUNb8muMaazL ii60LbTF4HmGAea8t57WWFWmoEb/I9AXBh2jAxUFzClPw/x1KKys1HGx60NLrmVLrIZf FwdxU+oE9wViEUo9A0DYjJ3AJ/OXsXUub17X6Xfu85NekPOOxA8cNaSz/IBq6Wm52Bil E04QBZT2rnY/gNW+eLd/4pOABu7bFEZAU8L6kn07nMVeTOP2xJHlJ+LU1Z6fiWLyVuZg 7FuA== MIME-Version: 1.0 In-Reply-To: References: <507E145E.9060008@davea.name> Date: Wed, 17 Oct 2012 23:34:08 +0100 Subject: Re: list comprehension question From: Oscar Benjamin To: Dwight Hutto Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org, d@davea.name X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350513251 news.xs4all.nl 6936 [2001:888:2000:d::a6]:41186 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31546 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.