Path: csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!1.eu.feeder.erje.net!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.05; 'cpython': 0.05; 'memory.': 0.05; 'url:pipermail': 0.05; '21,': 0.07; 'plenty': 0.07; 'pretend': 0.07; 'read-only': 0.07; 'table.': 0.07; 'integers': 0.09; 'mutable': 0.09; 'cc:addr:python-list': 0.10; 'thread': 0.10; 'python': 0.11; '11:59': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'immutable,': 0.16; 'immutable;': 0.16; 'language)': 0.16; 'mutability': 0.16; 'options)': 0.16; 'storing': 0.16; 'subject:?)': 0.16; 'wrote:': 0.16; 'memory': 0.17; 'string': 0.17; 'integer': 0.18; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; '(the': 0.22; 'am,': 0.23; '2015': 0.23; "python's": 0.23; 'header:In-Reply-To:1': 0.24; 'separate': 0.27; '(such': 0.27; 'message-id:@mail.gmail.com': 0.28; 'wasting': 0.29; 'url:python': 0.33; 'received:google.com': 0.34; 'could': 0.35; 'done': 0.35; 'but': 0.36; 'url:org': 0.36; 'so,': 0.37; 'subject:: ': 0.37; 'doing': 0.38; 'data': 0.40; 'subject: (': 0.40; 'some': 0.40; 'simple': 0.61; 'here.': 0.61; 'more': 0.62; 'skip:n 10': 0.63; 'total': 0.64; 'between': 0.65; 'safety': 0.66; 'prompt': 0.79; 'abandon': 0.84; 'chrisa': 0.84; 'distinguish': 0.84; "it'd": 0.84; 'safety.': 0.84; 'trades': 0.84; 'to:none': 0.90; 'disposal': 0.91; 'notion': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=6UJU50rF6bORpDyggOJ7KFwYcasvpZuuTgxMl5tTOCU=; b=imcHx/JZPohqAB6b9xW4Hk3v+OqB1LAg+b/jxVrkKAIDSZxPd21Tn2jRzbOMXhmam4 0micl7nzLYPAvLXSfbECyPve+AD72VB70wynfIWhgLr5vHlZ8YSds0lN/VSfZEsqV7U9 PhsPxkoP2Ud+sr8iWWQPf4+ShGLuxaw5UvtDU6SXdSnvyOeDoSg57oNWRcKou8VceIHk SeLy1H8UA56hhTDak0e1ZAHu4ESIGUzVfARfjiJlCgA0AKGFcHUwYgrlaNZDkrx0u3uh ClU5FlRrpQrJuc6PO8OKsHxy7c+wVXSmjMHqfXWJz89S40v/TyX3Yumow8we4Me0vxVG eXTQ== MIME-Version: 1.0 X-Received: by 10.42.43.199 with SMTP id y7mr19211143ice.12.1434853944032; Sat, 20 Jun 2015 19:32:24 -0700 (PDT) In-Reply-To: <762816ac-c744-480b-a9f9-a0110451c516@googlegroups.com> References: <3bbe49da-e989-4a8c-a8a9-75d3a786f508@googlegroups.com> <557056f9$0$13009$c3e8da3$5496439d@news.astraweb.com> <5570ce43$0$12991$c3e8da3$5496439d@news.astraweb.com> <55710b69$0$12980$c3e8da3$5496439d@news.astraweb.com> <6c78b294-efd6-4096-a572-1841aa71a5eb@googlegroups.com> <557182af$0$13014$c3e8da3$5496439d@news.astraweb.com> <33a2f501-5587-4fd9-91fa-7094d4f6c512@googlegroups.com> <81cb1232-ecf8-4cf0-b29c-ecf2ca47ade0@googlegroups.com> <5fa1f672-50de-4481-9c5b-2c68c4e30f12@googlegroups.com> <4fdc38b3-6b51-4f98-9ba3-42b265582fc0@googlegroups.com> <762816ac-c744-480b-a9f9-a0110451c516@googlegroups.com> Date: Sun, 21 Jun 2015 12:32:23 +1000 Subject: Re: Lawful != Mutable (was Can Python function return multiple data?) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1434853946 news.xs4all.nl 2838 [2001:888:2000:d::a6]:58355 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 6310 X-Received-Body-CRC: 889066761 Xref: csiph.com comp.lang.python:92925 On Sun, Jun 21, 2015 at 11:59 AM, Rustom Mody wrote= : > Recent thread on python ideas > https://mail.python.org/pipermail/python-ideas/2015-June/034177.html > > Since "python's immutable" =E2=89=A0 "really immutable", we now need a "r= eally immutable" That's because it requires mutable memory to keep track of reference counts. In a non-refcountinig Python, strings and integers can be truly immutable; that thread is suggesting (among other options) simply storing the refcounts in a separate table. Conceptually, a string or integer IS immutable, but CPython currently needs to be able to fiddle with some bookkeeping data about them, in order to pretend it has plenty of memory. A Python implementation could theoretically just abandon its strings whenever it's done with them, wasting gobs of memory in the process, and having them in read-only memory. More practically, a pure mark-and-sweep GC (such as MicroPython uses) trades prompt disposal for simple management, and in doing so, achieves (I think) the same total immutability. You have to distinguish between Python (the language) and CPython (the implementation) here. Python's notion of mutability has nothing to do with thread safety. You could achieve perfect thread safety for immutables by simply replicating them into every thread; it'd be inefficient, but perfectly legal. ChrisA