Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'argument': 0.05; 'received:134': 0.05; 'attribute': 0.07; 'compiler': 0.07; 'augmented': 0.09; 'below).': 0.09; 'tmp': 0.09; 'python': 0.11; '"a"': 0.16; 'bit.': 0.16; 'bytecode': 0.16; 'operators.': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'comparing': 0.24; '(see': 0.26; 'references': 0.26; 'second': 0.26; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'forgot': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'steven': 0.31; 'this.': 0.32; 'could': 0.34; 'but': 0.35; 'doubt': 0.36; 'should': 0.36; 'two': 0.37; 'subject:new': 0.38; 'saves': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'above,': 0.60; 'expression': 0.60; 'simple': 0.61; 'needing': 0.65; 'mar': 0.68; '2015': 0.84; 'optimisation': 0.84; 'optimized,': 0.84; 'proposal.': 0.84; 'favour': 0.91; 'subject:Proposal': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqcEAE0XJlWGuA9G/2dsb2JhbABch0vGJYJcAoIBAQEBAQEBhR4BAQQjVRELGAICBRYLAgIJAwIBAgFFEwgCiCa2A5FihHUBAQgCIIEhigqFAxaCUoFFAQSae4cHjVQig3GDMAEBAQ Date: Thu, 09 Apr 2015 09:32:23 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Proposal for new minor syntax References: <55167a22$0$13013$c3e8da3$5496439d@news.astraweb.com> <551685e2$0$12994$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <551685e2$0$12994$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428564816 news.xs4all.nl 2933 [2001:888:2000:d::a6]:43218 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88697 On 03/28/2015 11:43 AM, Steven D'Aprano wrote: > On Sat, 28 Mar 2015 08:53 pm, Steven D'Aprano wrote: > > >> It saves typing. It might even allow a micro-optimization in the generated >> bytecode (see below). > Oops, I forgot to include the "see below" bit. > > Comparing > > a = a.spam() > > a .= spam() > > > the Python compiler could perhaps optimize the second form and avoid needing > two references to "a" (once for the attribute lookup, once for the > binding). That's not very exciting when it comes to a simple expression > like the above, but consider: > > a[b][c].d.e[f].g = a[b][c].d.e[f].g.spam() > > > *If* that could be optimized, and I'm not certain it can be, that would be > an argument in favour of the proposal. I don't understand why you should doubt this. The optimisation is just the sames as with augmented operators. tmp = a[b][c].d.e[f] tmp.g = tmp.g.spam()