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


Groups > comp.lang.python > #18942

Re: copy on write

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.alt.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <edriscoll@wisc.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.023
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; '*not*': 0.05; ':-)': 0.06; 'c++,': 0.07; 'reason.': 0.07; 'header:In-reply-to:1': 0.09; 'immutable': 0.09; 'programmer': 0.10; 'am,': 0.12; 'c++': 0.12; 'subject:copy': 0.16; 'wrote:': 0.16; "wouldn't": 0.17; 'wonder': 0.23; 'objects,': 0.23; "python's": 0.24; '22,': 0.30; 'received:144': 0.30; 'semantics': 0.30; '(e.g.': 0.30; 'implementing': 0.32; 'suggested': 0.32; 'does': 0.32; 'objects': 0.32; 'implement': 0.32; 'header:User-Agent:1': 0.33; 'to:addr :python-list': 0.33; 'wondering': 0.34; 'charset:us-ascii': 0.36; 'with.': 0.37; 'received:128': 0.37; 'somewhat': 0.38; 'why': 0.39; 'either': 0.39; 'sense': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'effective': 0.61; 'fact,': 0.63; 'view': 0.64; 'ever': 0.64; 'perfect': 0.64; 'different.': 0.84; 'left,': 0.84; 'right)': 0.84; 'subject:write': 0.84; 'magical': 0.93
MIME-version 1.0
Content-transfer-encoding 7BIT
Content-type text/plain; CHARSET=US-ASCII; format=flowed
Date Fri, 13 Jan 2012 13:24:28 -0600
From Evan Driscoll <edriscoll@wisc.edu>
Subject Re: copy on write
In-reply-to <9nb5ubFu17U2@mid.individual.net>
To python-list@python.org
X-Spam-Report AuthenticatedSender=yes, SenderIP=128.105.181.52
X-Spam-PmxInfo Server=avs-9, Version=5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.13.191217, SenderIP=128.105.181.52
References <mailman.4709.1326455724.27778.python-list@python.org> <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmr-069xisN6h4Cxt77vWbb+VhtMb-LRNfvyphwGz0C5GA@mail.gmail.com> <mailman.4714.1326462667.27778.python-list@python.org> <jephmt$hhp$1@reader1.panix.com> <mailman.4718.1326473361.27778.python-list@python.org> <9nb5ubFu17U2@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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4728.1326486286.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326486286 news.xs4all.nl 6879 [2001:888:2000:d::a6]:57363
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18942

Show key headers only | View raw


On 01/13/2012 10:54 AM, Neil Cerutti wrote:
> If you've ever implemented operator=, operator+, and operator+=
> in C++ you'll know how and why they are different.

At the same time, you'd also know that that implementing them in such a 
way that 'a += b' does *not* perform the same action as 'a = a + b' is 
considered very bad-mannered.

In fact, it's often suggested (e.g. in "More Effective C++"'s Item 22, 
though this is not the main thrust of that section) to implement 
operator+ in terms of += to ensure that this is the case:
  MyType operator+ (MyType left, MyType right) {
      MyType copy = left; copy += right; return copy;
  }

> A C++
> programmer would be wondering how either can work on immutable
> objects, and that's where Python's magical rebinding semantics
> come into play.

IMO a C++ programmer wouldn't be likely to wonder that much at all 
because he or she wouldn't view the objects as immutable to begin with. 
:-) 'x = 5; x += 1;' makes perfect sense in C++, just for a somewhat 
different reason.

Evan

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


Thread

copy on write Eduardo Suarez-Santana <esuarez@itccanarias.org> - 2012-01-13 11:33 +0000
  Re: copy on write Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-13 12:10 +0000
    Re: copy on write Chris Angelico <rosuav@gmail.com> - 2012-01-13 23:30 +1100
      Re: copy on write Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-13 13:04 +0000
        Re: copy on write Ethan Furman <ethan@stoneleaf.us> - 2012-01-13 10:40 -0800
          Re: copy on write 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-13 14:26 -0800
          Re: copy on write 88888 Dihedral <dihedral88888@googlemail.com> - 2012-01-13 14:26 -0800
        Re: copy on write John O'Hagan <research@johnohagan.com> - 2012-02-02 14:18 +1100
        Re: copy on write Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-02-02 01:34 -0500
        Re: copy on write John O'Hagan <research@johnohagan.com> - 2012-02-02 19:11 +1100
          Re: copy on write Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-02 09:16 +0000
            Re: copy on write Hrvoje Niksic <hniksic@xemacs.org> - 2012-02-02 11:53 +0100
              Re: copy on write MRAB <python@mrabarnett.plus.com> - 2012-02-02 16:28 +0000
              Re: copy on write Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-02-02 12:21 -0500
            Re: copy on write John O'Hagan <research@johnohagan.com> - 2012-02-03 01:17 +1100
            Re: copy on write Terry Reedy <tjreedy@udel.edu> - 2012-02-02 12:25 -0500
            Re: copy on write John O'Hagan <research@johnohagan.com> - 2012-02-03 14:08 +1100
              Re: copy on write Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-03 05:04 +0000
                Re: copy on write Chris Angelico <rosuav@gmail.com> - 2012-02-03 16:28 +1100
                Re: copy on write Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-03 07:35 -0800
                Re: copy on write Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2012-02-03 10:08 +0100
                Re: copy on write John O'Hagan <research@johnohagan.com> - 2012-02-03 21:47 +1100
                Re: copy on write Wolfram Hinderer <wolfram.hinderer@googlemail.com> - 2012-02-05 06:09 -0800
                Re: copy on write "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2012-02-03 16:15 +0000
      Re: copy on write Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-02-02 11:42 +0100
    Re: copy on write Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-01-13 08:50 -0500
      Re: copy on write Grant Edwards <invalid@invalid.invalid> - 2012-01-13 15:13 +0000
        Re: copy on write Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-01-13 11:48 -0500
          Re: copy on write Neil Cerutti <neilc@norwich.edu> - 2012-01-13 16:54 +0000
            Re: copy on write Grant Edwards <invalid@invalid.invalid> - 2012-01-13 18:15 +0000
              Re: copy on write Chris Angelico <rosuav@gmail.com> - 2012-01-14 05:26 +1100
                Re: copy on write Grant Edwards <invalid@invalid.invalid> - 2012-01-13 19:30 +0000
                Re: copy on write Neil Cerutti <neilc@norwich.edu> - 2012-01-13 20:11 +0000
            Re: copy on write Evan Driscoll <edriscoll@wisc.edu> - 2012-01-13 13:24 -0600
              Re: copy on write Neil Cerutti <neilc@norwich.edu> - 2012-01-13 21:20 +0000
                Re: copy on write Evan Driscoll <edriscoll@wisc.edu> - 2012-01-13 16:48 -0600
                Re: copy on write 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-02 05:33 -0800
                Re: copy on write Evan Driscoll <edriscoll@wisc.edu> - 2012-02-02 15:20 -0600
                Re: copy on write 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-02 05:33 -0800
                Re: copy on write 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-03 14:16 -0800
                Re: copy on write 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-03 14:16 -0800
          Re: copy on write Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-01 19:51 -0800
            Re: copy on write Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-02 05:31 +0000

csiph-web