Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61463
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '(even': 0.05; 'output': 0.05; '(b)': 0.07; 'assignment': 0.07; 'cache': 0.07; 'suppose': 0.07; 'variables': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'variables.': 0.09; 'assignments': 0.16; 'lhs': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'rhs': 0.16; 'tuple': 0.16; 'variables,': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'seems': 0.21; 'header:User-Agent:1': 0.23; '(a)': 0.24; 'connected': 0.24; 'mon,': 0.24; 'asking': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; '(c)': 0.29; 'dec': 0.30; 'start,': 0.30; 'code': 0.31; 'end,': 0.31; 'subject:some': 0.31; 'tuples': 0.31; 'guess': 0.33; 'but': 0.35; 'method': 0.36; 'similar': 0.36; 'two': 0.37; 'performance': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'dave': 0.60; 'numbers': 0.61; 'simple': 0.61; 'more': 0.64; 'reads': 0.68; 'received:109': 0.72; 'faster.': 0.84; 'angel': 0.91; 'joel': 0.91; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robin Becker <robin@reportlab.com> |
| Subject | Re: squeeze out some performance |
| Date | Tue, 10 Dec 2013 12:54:13 +0000 |
| References | <ce6477c1-29c0-43b3-9e56-336a5825869b@googlegroups.com> <9df6ccd7-828d-43be-ac49-fe1c6a38bae7@googlegroups.com> <CAPM-O+wyt_7VyO+yFO9eVDUnqJAxr5fa9rAONQHCbFgzkbJdhw@mail.gmail.com> <52A5E7BC.5090600@chamonix.reportlab.co.uk> <almarsoft.2469747325533878265@news.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 109.174.168.73 |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 |
| In-Reply-To | <almarsoft.2469747325533878265@news.gmane.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3823.1386680060.18130.python-list@python.org> (permalink) |
| Lines | 54 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386680060 news.xs4all.nl 2875 [2001:888:2000:d::a6]:35490 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61463 |
Show key headers only | View raw
On 09/12/2013 20:46, Dave Angel wrote: > On Mon, 09 Dec 2013 15:54:36 +0000, Robin Becker <robin@reportlab.com> wrote: >> On 06/12/2013 22:07, Joel Goldstick wrote: >> > end, start = start, end > >> a similar behaviour for simple assignments > >> for less than 4 variables the tuple method is faster. > > What does speed have to do with it? When you want to swap two variables, the > tuple assignment reads better. > Well the OP is asking about performance so I guess the look and feel might be sacrificed for speed in some circumstances. The tuple approach is more appealing when the lhs & rhs are connected, but it seems that even for more general assignments the tuple assignment may be faster for small numbers of variables. Looking at the output of dis for this case d,e,f=c,b,a it seems that we get code like this LOAD_NAME 3 (c) LOAD_NAME 2 (b) LOAD_NAME 1 (a) ROT_THREE ROT_TWO STORE_NAME 4 (d) STORE_NAME 5 (e) STORE_NAME 6 (f) for d = c e = b f = a we get this LOAD_NAME 3 (c) STORE_NAME 4 (d) LOAD_NAME 2 (b) STORE_NAME 5 (e) LOAD_NAME 1 (a) STORE_NAME 6 (f) which is not obviously slower, but I consistently get the former to be faster. I suppose it's a cache issue or something. However, for this particular case when the variables are not connected I find the tuple assignment less pythonic, but perhaps faster (even though in this case no tuples are built). -- Robin Becker
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-06 00:47 -0800
Re: squeeze out some performance Jeremy Sanders <jeremy@jeremysanders.net> - 2013-12-06 10:46 +0100
Re: squeeze out some performance Chris Angelico <rosuav@gmail.com> - 2013-12-06 23:13 +1100
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-06 08:29 -0800
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-06 16:36 +0000
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-06 08:44 -0800
Re: squeeze out some performance John Ladasky <john_ladasky@sbcglobal.net> - 2013-12-06 08:52 -0800
Re: squeeze out some performance Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-06 17:07 -0500
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-06 22:38 +0000
Re: squeeze out some performance Dan Stromberg <drsalists@gmail.com> - 2013-12-06 15:01 -0800
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-09 06:19 -0800
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 14:52 +0000
Re: squeeze out some performance Robin Becker <robin@reportlab.com> - 2013-12-09 15:54 +0000
Re: squeeze out some performance Dave Angel <davea@davea.name> - 2013-12-09 15:46 -0500
Re: squeeze out some performance Robin Becker <robin@reportlab.com> - 2013-12-10 12:54 +0000
Re: squeeze out some performance Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-09 23:57 +0000
Re: squeeze out some performance Robert Voigtländer <r.voigtlaender@gmail.com> - 2013-12-10 04:14 -0800
csiph-web