Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'received:134': 0.05; 'nested': 0.07; 'augmented': 0.09; 'rewrite': 0.09; 'sure,': 0.09; 'tmp': 0.09; 'class:': 0.16; 'evaluating': 0.16; 'evaluations': 0.16; 'rewriting': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'header :User-Agent:1': 0.23; 'example.': 0.24; 'second': 0.26; 'header :In-Reply-To:1': 0.27; 'point': 0.28; '[1]': 0.29; 'am,': 0.29; "doesn't": 0.30; '[2]': 0.30; 'code': 0.31; 'closer': 0.31; 'one,': 0.35; 'but': 0.35; 'example,': 0.37; 'wrong': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; '12,': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'ian': 0.60; 'first': 0.61; 'more': 0.64; 'different': 0.65; 'mar': 0.68; 'natural': 0.68; 'evaluate': 0.72; 'surprise': 0.74; 'hand': 0.80; 'conclude': 0.84; 'pardon': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwKAMJBIFOGuA9G/2dsb2JhbABaxWYBAoExgxkBAQEEeBELGAkWDwkDAgECAUUTBgICh3XMCoVZF45jFoQiBJhFhjWLeIMu Date: Wed, 12 Mar 2014 12:21:05 +0100 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Tuples and immutability References: <0d76f320-a39e-44e9-85a2-74220b646566@googlegroups.com> <531ffe70$0$2923$c3e8da3$76491128@news.astraweb.com> <53202B57.7060504@rece.vub.ac.be> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394623266 news.xs4all.nl 2893 [2001:888:2000:d::a6]:48784 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68273 Op 12-03-14 10:51, Ian Kelly schreef: > On Wed, Mar 12, 2014 at 3:39 AM, Antoon Pardon > wrote: >> The documentation is wrong at that point as the following code illustrates. > Either way it still has to do a getitem and a setitem, but if you have > a more nested structure then the extra getitems are not repeated. For > example, using your logdict class: Sure, but the documentation doesn't say for sufficiently nested structures some evaluations are not repeated. Take the following example. | tab['key'] = [1] | tab['key'] += [2] Now let us rewrite that second statment in two different ways. | tab['key'] = tab['key'] + [2] or | tmp = tab['key'] | tmp += [2] Now which of these two rewritings is closer to the augmented concatenation? A natural reading of the documentation would conclude the second one, because in that case we only need to evaluate tab['key'] once as righthand sided. However it turns out the augmented concantenation is closer to the first rewriting here, evaluating tab['key'] twice once a lefthand sided and once as right hand sided, which IMO will surprise people that rely on the documentation. -- Antoon Pardon