Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12686
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.mb-net.net!open-news-network.org!.POSTED!not-for-mail |
|---|---|
| From | Bart Kastermans <bkasterm@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: List comprehension timing difference. |
| Date | Fri, 02 Sep 2011 20:15:11 -0600 |
| Organization | MB-NET.NET for Open-News-Network e.V. |
| Lines | 18 |
| Message-ID | <87bov29xsg.fsf@gmail.com> (permalink) |
| References | <87zkinkcht.fsf@gmail.com> <mailman.676.1314925972.27778.python-list@python.org> <87sjofjbh1.fsf@gmail.com> <07906043-d732-43ca-8313-bee4746eca75@fi7g2000vbb.googlegroups.com> |
| NNTP-Posting-Host | kasterma.colorado.edu |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | gwaiyur.mb-net.net 1315016114 30314 128.138.150.65 (3 Sep 2011 02:15:14 GMT) |
| X-Complaints-To | abuse@open-news-network.org |
| NNTP-Posting-Date | Sat, 3 Sep 2011 02:15:14 +0000 (UTC) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| X-User-ID | U2FsdGVkX19rSrLj2WlKYLkWHgP7GgFvoEV22pRNQc8m0WE70hazyfavLAUnPQL0 |
| Cancel-Lock | sha1:qboNUeJz6cXAexVFQJ9c7bq3t3s= sha1:g7BCdPgRjuymeGfGz+UybOCfgAg= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12686 |
Show key headers only | View raw
ting@thsu.org writes: > On Sep 2, 9:54 am, Bart Kastermans <bkast...@gmail.com> wrote: >> if d(a,b) == 1 and a < b: > > It will probably be faster if you reverse the evaluation order of that > expression. > > if a<b and d(a,b)==1: > > That way the d() function is called less than half the time. Of course > this assumes that a<b is a faster evaluation than d(a,b), but I think > that's true for your example. > -- > // T.Hsu Indeed makes quite a difference, goes from 275 seconds down to 153 seconds.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
List comprehension timing difference. Bart Kastermans <bkasterm@gmail.com> - 2011-09-01 18:35 -0600
Re: List comprehension timing difference. MRAB <python@mrabarnett.plus.com> - 2011-09-02 02:12 +0100
Re: List comprehension timing difference. Bart Kastermans <bkasterm@gmail.com> - 2011-09-02 07:54 -0600
Re: List comprehension timing difference. ting@thsu.org - 2011-09-02 07:50 -0700
Re: List comprehension timing difference. Bart Kastermans <bkasterm@gmail.com> - 2011-09-02 20:15 -0600
csiph-web