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


Groups > comp.lang.python > #88697

Re: Proposal for new minor syntax

Date 2015-04-09 09:32 +0200
From Antoon Pardon <antoon.pardon@rece.vub.ac.be>
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>
Newsgroups comp.lang.python
Message-ID <mailman.158.1428564816.12925.python-list@python.org> (permalink)

Show all headers | 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