Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88697

Re: Proposal for new minor syntax

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 <antoon.pardon@rece.vub.ac.be>
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 <antoon.pardon@rece.vub.ac.be>
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 <CAPauRLMMAT-OffHTYW6GPybAZzouc7H9BjrmvVQiSig0X3x+ig@mail.gmail.com> <mailman.278.1427489337.10327.python-list@python.org> <GplRw.1325750$ls6.204434@fx16.am4> <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 <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.158.1428564816.12925.python-list@python.org> (permalink)
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

Show key headers only | View raw


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() 

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Proposal for new minor syntax Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-27 14:48 -0600
  Re: Proposal for new minor syntax BartC <bc@freeuk.com> - 2015-03-27 23:08 +0000
    Re: Proposal for new minor syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 20:53 +1100
      Re: Proposal for new minor syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 21:43 +1100
        Re: Proposal for new minor syntax Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-04-09 09:32 +0200
      Re: Proposal for new minor syntax BartC <bc@freeuk.com> - 2015-03-28 13:38 +0000
        Re: Proposal for new minor syntax Mario Figueiredo <marfig@gmail.com> - 2015-03-28 16:05 +0100
          Re: Proposal for new minor syntax Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-28 22:15 -0600
            Re: Proposal for new minor syntax Rustom Mody <rustompmody@gmail.com> - 2015-03-28 21:50 -0700
  Re: Proposal for new minor syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 21:01 +1100

csiph-web