Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!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; 'operator': 0.03; 'value,': 0.03; 'cpython': 0.05; 'memory.': 0.05; 'retrieved': 0.05; 'variable,': 0.07; 'cc:addr:python-list': 0.09; 'differently.': 0.09; "object's": 0.09; 'object;': 0.09; 'pointers': 0.09; 'python': 0.10; 'interpreter': 0.15; '(there': 0.16; 'code),': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'language)': 0.16; 'pointers,': 0.16; 'pointers.': 0.16; 'python),': 0.16; 'somewhere.': 0.16; 'spec,': 0.16; 'subject:versus': 0.16; 'wrote:': 0.16; 'string': 0.17; 'attribute': 0.18; 'bytes': 0.18; 'comparing': 0.18; 'integer': 0.18; 'pointer': 0.18; 'refers': 0.18; 'language': 0.19; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(the': 0.22; 'assign': 0.22; 'ctypes': 0.22; 'object.': 0.22; 'sep': 0.22; "python's": 0.23; 'references': 0.23; 'sat,': 0.23; 'implemented': 0.24; 'header:In-Reply-To:1': 0.24; '(which': 0.26; 'supported': 0.27; 'bugs': 0.27; 'message-id:@mail.gmail.com': 0.27; 'gnu': 0.27; 'object,': 0.27; 'values': 0.28; 'arithmetic': 0.29; 'objects': 0.29; "i'm": 0.30; 'probably': 0.31; "can't": 0.32; 'implement': 0.32; 'aside': 0.32; 'point': 0.33; 'accessible': 0.33; 'reference,': 0.33; '(for': 0.34; 'languages': 0.34; 'received:google.com': 0.35; 'exist': 0.35; 'identity': 0.35; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; '12,': 0.37; 'someone': 0.38; 'copying': 0.38; 'sure': 0.39; 'does': 0.39; 'still': 0.40; 'different': 0.63; 'within': 0.64; 'series': 0.65; 'compliant': 0.66; "they're": 0.66; 'subjectcharset:utf-8': 0.71; '100%': 0.72; 'special': 0.73; 'actually,': 0.84; 'brain,': 0.84; 'chrisa': 0.84; 'diagnosing': 0.84; "else's": 0.84; 'to:none': 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; bh=vbUMh9UIDDgfuJYRS8pvkOHPmakWHShvyMiCyKfVaII=; b=JER4cJVBZCDDi5XrWLzayszumnmlLRvH3lxE4HGVEuJXDQIq6TfkF3TMlUyZal9L0V Cz5IueJW5+GIp1y424eigvOk+mjWYbltROCST7+5hXvcWBa299t3gDDQNs3VpbKYfpFz 4VT2Hvj8TTLMaAegssLpYeaf424KWk7z9lL4V9hqSnSdxDMYH3Cti3VrQsZ5ySyivLIC I7szmtGGxbLGhAE0HEn61b0tnfpbqL76PvDfIhC3Jcx2vVd1sS5VhVE8mETgSGKvcycH HdZ8X7e1TCY0/k/jcHKeQHXRhTED/MbPDDh6XdOfpJQEcKVexLwQsNfKNlhYG+a5aa4H nGwQ== MIME-Version: 1.0 X-Received: by 10.107.132.144 with SMTP id o16mr8942134ioi.31.1442037755605; Fri, 11 Sep 2015 23:02:35 -0700 (PDT) In-Reply-To: References: <14afe27e-0bd5-410f-8e64-0f31d496ebf2@googlegroups.com> <55F36B4C.9020007@gmail.com> <1442016698.95299.381478313.2487CA0E@webmail.messagingengine.com> <85mvws6z45.fsf_-_@benfinney.id.au> <85io7g6xy4.fsf@benfinney.id.au> Date: Sat, 12 Sep 2015 16:02:35 +1000 Subject: =?UTF-8?B?UmU6IFRlcm1pbm9sb2d5OiDigJxyZWZlcmVuY2XigJ0gdmVyc3VzIOKAnHBvaW50ZXI=?= =?UTF-8?B?4oCd?= From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1442037766 news.xs4all.nl 23813 [2001:888:2000:d::a6]:57340 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96409 On Sat, Sep 12, 2015 at 3:03 PM, Random832 wrote: >> You can't, for example, keep the old reference (there are no references >> to references in Python), because they're not accessible as values in >> themselves. Once you assign a different reference, the old one is gone >> and can't be found again. > > You can keep it by copying it to somewhere. The pointer is the value, > not the variable, you don't _need_ a reference to it. CPython happens to implement references using pointers, which leads a lot of people to think that Python's references are pointers in disguise. But Python (the language) does not have any concept of pointers or memory. An integer is not a GNU Multiprecision Bignum object, it is simply an integer. A string is not a series of bytes in Latin-1/UCS-2/UCS-4, it is a series of codepoints. Aside from fiddling around with ctypes (which isn't a supported action), there is nothing you can do within Python to find out what a reference "is"; there is literally ONE operation you can do with a reference, and that's to get at the object it refers to. (For example, you might think that the 'is' operator is comparing two references to see if they point to the same object. In CPython, it probably is implemented as a pointer comparison; but actually, it's comparing two objects to see if they're the same object.) Python does not have pointers, not because you can't do arithmetic on those pointers, but because they do not exist in the language spec. The Python interpreter in my brain, which I use frequently when diagnosing bugs (whether in my own or someone else's code), does not have pointers; I'm not prepared to guarantee that it's 100% compliant with the spec, but I know for sure that it _could be_, without adding any notion of pointers. C has pointers, and still would even pointer arithmetic were disallowed. The languages are architected differently. (Oh, and an object's identity is a special attribute of that object. It's not like its location in memory, which is an attribute of the reference to the object; it's a number that can be retrieved from the object itself.) ChrisA