Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'oct': 0.02; 'python': 0.08; 'def': 0.13; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '2.7.2': 0.16; '[gcc': 0.16; 'example?': 0.16; 'id;': 0.16; 'linux2': 0.16; 'subject:copy': 0.16; '>>>': 0.18; 'thanks,': 0.18; 'working.': 0.18; 'seems': 0.19; 'mechanism': 0.21; 'wonder': 0.23; 'expect': 0.26; 'class': 0.29; 'anyone': 0.31; 'values': 0.32; 'header:User-Agent:1': 0.33; 'to:addr :python-list': 0.33; 'there': 0.33; 'however,': 0.35; 'header:Received:8': 0.36; 'equal': 0.36; 'received:org': 0.37; 'skip:_ 10': 0.37; 'to:addr:python.org': 0.40; 'type': 0.60; 'more': 0.61; 'subject:write': 0.84 X-Virus-Scanned: Correo Analizado por Casiopea. ITC, Dep. Informatica y Comunicaciones Date: Fri, 13 Jan 2012 11:33:24 +0000 From: Eduardo Suarez-Santana User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20120104 Thunderbird/8.0 MIME-Version: 1.0 To: Subject: copy on write Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326455724 news.xs4all.nl 6844 [2001:888:2000:d::a6]:50999 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18910 I wonder whether this is normal behaviour. I would expect equal sign to copy values from right to left. However, it seems there is a copy-on-write mechanism that is not working. Anyone can explain and provide a working example? Thanks, -Eduardo $ python Python 2.7.2 (default, Oct 31 2011, 11:54:55) [GCC 4.5.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class n: ... def __init__(self, id, cont): ... self.id = id; ... self.cont = cont; ... >>> r={'a':1}; >>> d={}; >>> d['x']=r; >>> d['y']=r; >>> x1 = n('x',d['x']); >>> y1 = n('y',d['y']); >>> x1.cont['a']=2; >>> y1.cont {'a': 2} >>>