Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!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.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'assign': 0.04; 'header:In- reply-to:1': 0.09; 'statement.': 0.09; 'c++': 0.12; '(besides': 0.16; 'subject:copy': 0.16; 'wrote:': 0.16; 'discussion': 0.21; 'so.': 0.21; 'obviously': 0.23; '(where': 0.23; 'object,': 0.24; 'pm,': 0.26; 'at.': 0.30; 'received:144': 0.30; 'semantics': 0.30; 'thanks': 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python- list': 0.33; 'combination': 0.36; 'charset:us-ascii': 0.36; 'reference': 0.37; 'but': 0.37; 'received:128': 0.37; 'getting': 0.37; 'should': 0.38; 'either': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'difference': 0.40; 'design': 0.61; 'your': 0.61; 'behaviors': 0.67; 'stand': 0.72; 'different.': 0.84; 'subject:write': 0.84 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII; format=flowed Date: Fri, 13 Jan 2012 16:48:29 -0600 From: Evan Driscoll Subject: Re: copy on write In-reply-to: <9nblhhFr5bU1@mid.individual.net> To: python-list@python.org X-Spam-Report: AuthenticatedSender=yes, SenderIP=128.105.181.52 X-Spam-PmxInfo: Server=avs-14, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.13.223618, SenderIP=128.105.181.52 References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326498530 news.xs4all.nl 6870 [2001:888:2000:d::a6]:39424 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18952 On 01/13/2012 03:20 PM, Neil Cerutti wrote: > They perform the same action, but their semantics are different. > operator+ will always return a new object, thanks to its > signature, and operator+= shall never do so. That's the main > difference I was getting at. I was talking about the combination of + and =, since the discussion is about 'a = a + b' vs 'a += b', not 'a + b' vs 'a += b' (where the differences are obvious). And I stand by my statement. In 'a = a + b', operator+ obviously returns a new object, but operator= should then go and assign the result to and return a reference to 'a', just like how 'a += b' will return a reference to 'a'. If you're working in C++ and overload your operators so that 'a += b' and 'a = a + b' have different observable behaviors (besides perhaps time), then either your implementation is buggy or your design is very bad-mannered. Evan