Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31497
| 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 | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.055 |
| X-Spam-Evidence | '*H*': 0.89; '*S*': 0.00; 'messages.': 0.04; 'subject:skip:c 10': 0.07; 'subject:question': 0.08; 'cc:addr :python-list': 0.10; 'means.': 0.16; 'nesting': 0.16; 'readable': 0.16; 'wrote:': 0.17; 'earlier': 0.21; 'libraries': 0.22; 'help.': 0.22; 'cc:2**0': 0.23; 'kevin': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'correct': 0.28; 'subject:list': 0.28; 'faster,': 0.29; 'loop,': 0.29; 'case,': 0.29; "i'm": 0.29; '(and': 0.32; 'could': 0.32; 'much.': 0.33; 'likely': 0.33; 'list': 0.35; 'faster': 0.35; 'said,': 0.35; 'especially': 0.35; 'doing': 0.35; 'but': 0.36; "didn't": 0.36; 'two': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'shows': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'think': 0.40; 'your': 0.60; 'most': 0.61; 'more': 0.63; 'header :Reply-To:1': 0.68; 'teach': 0.69; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'difference.': 0.84; 'affected.': 0.91; 'yours.': 0.93; 'hand,': 0.97 |
| Date | Wed, 17 Oct 2012 08:32:43 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | Kevin Anthony <kevin.s.anthony@gmail.com> |
| Subject | Re: list comprehension question |
| References | <CA+C4C6f=24oD4seHY_-h1F0GMvBTWNYbzTABXOdtKkAZtE9hdQ@mail.gmail.com> <507E145E.9060008@davea.name> <CA+C4C6cjha4bMZ9gyx5fTp0c_nfFQxRGu31dGNMjgHQBu73=ig@mail.gmail.com> |
| In-Reply-To | <CA+C4C6cjha4bMZ9gyx5fTp0c_nfFQxRGu31dGNMjgHQBu73=ig@mail.gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:pHAPeVShOUizAS40uu+A6xUPA1k19V7Z9oK6MFp4WEx lo4AOY6SjpbXDva5me64j2osAEAEIOsv4t+uqrXFVLN5Nvgia2 yS/JGQcTt5XILetTS3FYliogdnPxcPSVaxhMbkiz5aBhxPLqPE AFEv5TSITutfBOM5Vrqk7NKKn9Lb2rYOduVuJcySAwz7tQs9vC GBiOSeWk/LsHrRVtJhqpE6MbWy1ZBueQXdM/KF1Ml3vP1UialV kqS2lQgekuozwakLe/Ua1X09jZEnk/hqUi9mX8itzmFIvdWj2q zh8xhQt40zIXyVla1Uvd4y7XdvS6DCtRjXOOqtHwan7FDSJxg= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | d@davea.name |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2341.1350477185.27098.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350477185 news.xs4all.nl 6968 [2001:888:2000:d::a6]:44097 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31497 |
Show key headers only | View raw
On 10/17/2012 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. > (Please don't top-post; it ruins the ordering. In these forums, put your response after the part you quote from earlier messages. Or even better, after each part you quote. Then trim off the parts you didn't reference.) list comprehensions CAN be much faster, but not necessarily. The most complex a loop, the less likely it'll help much. In any case, only the inner loop will be affected. Nesting two list comprehensions will make a trivial difference. On the other hand, Hans Mulder shows some other factoring which seems much more readable than yours. Studying (and testing) those could teach you a lot about comprehensions, as well as about the libraries that can help. Note especially what zip(*b) yields, and think about what it means. -- DaveA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: list comprehension question Dave Angel <d@davea.name> - 2012-10-17 08:32 -0400
Re: list comprehension question rusi <rustompmody@gmail.com> - 2012-10-17 07:06 -0700
Re: list comprehension question rusi <rustompmody@gmail.com> - 2012-10-17 07:33 -0700
Re: list comprehension question Dave Angel <d@davea.name> - 2012-10-17 10:36 -0400
Re: list comprehension question 88888 Dihedral <dihedral88888@googlemail.com> - 2012-10-17 07:45 -0700
Re: list comprehension question 88888 Dihedral <dihedral88888@googlemail.com> - 2012-10-17 07:45 -0700
Re: list comprehension question rusi <rustompmody@gmail.com> - 2012-10-17 07:50 -0700
Re: list comprehension question 88888 Dihedral <dihedral88888@googlemail.com> - 2012-10-17 08:06 -0700
csiph-web