Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'root': 0.05; 'tree': 0.05; 'binary': 0.07; 'referring': 0.07; 'deemed': 0.09; 'implemented.': 0.09; 'insertion': 0.09; 'references.': 0.09; 'dismiss': 0.16; 'mutable': 0.16; 'partly': 0.16; 'thread,': 0.16; 'top-level': 0.16; 'sat,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'written': 0.21; 'balancing': 0.24; "shouldn't": 0.24; 'earlier': 0.24; 'header:In-Reply-To:1': 0.27; 'external': 0.29; 'message- id:@mail.gmail.com': 0.30; 'node': 0.31; 'noted': 0.31; 'object.': 0.31; 'another': 0.32; 'maybe': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'object,': 0.36; 'possible': 0.36; 'implement': 0.38; 'somebody': 0.38; 'stable': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'up,': 0.60; 'mentioned': 0.61; "you're": 0.61; 'first': 0.61; 'such': 0.63; 'different': 0.65; 'needs,': 0.65; 'mar': 0.68; 'balanced': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=p/fUIGHdmaNioOKdmjBU1su2CqTVe2apTwK/O9BhR+8=; b=jyyBBWf6HTIrlHodO1F6TTmcK12Q+rggrWhdDEIUoDQGBF+Ai/fizc+yvOFJGA3sMI 1uiZzSPdf2TawQM1xqZzmc0mt7Ko59Jj6zds6lpYPCnHN75qcIbDcvfZDunm+P47a2a9 DJpCL/Im0wCm2sjgs4wchYlznv6xRzqf3gHuh+cf2KZgEdToDshHB7o4kzzSKu5Py/iz Z6A7nzeZEXZZ1/YVDUvoKMWNL5venXtQsMbPO4w/dsleLH5tT2pNBRXMR2/ePaAbbIy3 YrA0OgMrXHHUQrxhKFStFbhJlq19diP2Kx6+WkSMHSN7pVnlFBi4hJZIrajZD2Jn4T9a 0Euw== X-Received: by 10.66.151.205 with SMTP id us13mr31352779pab.93.1394333765528; Sat, 08 Mar 2014 18:56:05 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Sat, 8 Mar 2014 19:55:25 -0700 Subject: Re: Tuples and immutability To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394333769 news.xs4all.nl 2830 [2001:888:2000:d::a6]:54496 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68063 On Sat, Mar 8, 2014 at 5:45 PM, Gregory Ewing wrote: > Ian Kelly wrote: > >> I already mentioned this earlier in the thread, but a balanced binary >> tree might implement += as node insertion and then return a different >> object if the balancing causes the root node to change. > > > That would be a really bad way to design a binary tree > implementation. What if there is another reference to > the tree somewhere? It's still going to be referring to > the old root object, and will have an incoherent view > of the data -- partly old and partly new. > > If you're going to have a mutable tree, it needs to be > encapsulated in a stable top-level object. Well, as I parenthetically noted the first time I brought it up, "whether this is good design is tangential; it's a possible design". The language shouldn't be written such that only those designs deemed "good" by some external committee can be implemented. What you dismiss as "really bad" may be exactly what somebody else needs, and maybe they intend that there won't be other references.