Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?) Date: Thu, 26 Nov 2015 22:49:14 +1100 Lines: 49 Message-ID: References: <56550273$0$1585$c3e8da3$5496439d@news.astraweb.com> <5655f27b$0$1614$c3e8da3$5496439d@news.astraweb.com> <6imd5b9it55sucrcl95o95tppro7errfsi@4ax.com> <871tbdf2o0.fsf@elektro.pacujo.net> <70qd5b9lbtjlsotn7d21gor4rd67o79ou7@4ax.com> <85lh9l9f6e.fsf_-_@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de MSK0YUR+4tqVHtKkTQUwzAxzeTRA8QGqFKQ1cl1NXZfw== 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; 'received:209.85.223': 0.03; 'pypy': 0.07; 'cc:addr:python-list': 0.09; '16-bit': 0.09; 'exiting': 0.09; 'integers': 0.09; 'minus': 0.09; 'pointers': 0.09; 'subject:Object': 0.09; 'stored': 0.10; 'python': 0.10; 'explicitly': 0.15; 'thu,': 0.15; 'value.': 0.15; 'assumptions': 0.16; 'at.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'heap': 0.16; 'ids.': 0.16; 'presume': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sense,': 0.16; 'subject: \n (': 0.16; 'subject:?)': 0.16; 'unwarranted': 0.16; "variable's": 0.16; 'wrote:': 0.16; 'translation': 0.16; 'memory': 0.17; 'integer': 0.18; 'numerical': 0.18; 'pointer': 0.18; 'language': 0.19; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'machine': 0.21; 'location,': 0.22; 'appears': 0.23; 'fit': 0.23; 'bit': 0.23; 'seems': 0.23; 'unlike': 0.23; 'header:In-Reply-To:1': 0.24; 'figure': 0.27; 'least': 0.27; 'message-id:@mail.gmail.com': 0.27; 'object,': 0.27; '(maybe': 0.29; 'guarantees': 0.29; 'objects': 0.29; 'themselves': 0.29; "i'm": 0.30; 'connection': 0.30; "can't": 0.32; 'getting': 0.33; 'rule': 0.33; 'surprised': 0.33; 'received:google.com': 0.35; 'i.e.': 0.35; 'identity': 0.35; 'nov': 0.35; 'requiring': 0.35; 'but': 0.36; 'too': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'detail': 0.38; 'received:209': 0.38; 'why': 0.39; 'takes': 0.39; 'still': 0.40; 'share': 0.61; 'skip:u 10': 0.61; 'between': 0.65; 'promise': 0.66; "they're": 0.66; '26,': 0.72; 'chrisa': 0.84; 'compliant.': 0.84; 'farrance': 0.84; 'subject:location': 0.84; 'subject:necessary': 0.84; 'to:none': 0.91; 'address;': 0.91; 'promised': 0.91; 'shares': 0.93 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=gzr63rjoMY+oRZe6qFnC2vAzAk/TmzNdel/qnF1LI80=; b=njpNijZmOG0kDLcWsfEVNUuFMSoh84VbS01e8vYlnVonNt8FPX+em0u5e6IDyOLeZq nuKhRi1qw7jS9BWfKAFbxh2KLb4ueBomL2Gi6N5p+MBIA3gtkVJKXAHQNyXqxLGzKKJy 7pEhV48RuXzzQyngx4Rz5G5yvIv5qPXO2ovDODngGSybtHsMnULT0Cag7BJuBKg9Eonv +1MeSPvrjQVbEDc61cpHsOaAVPyoado/7sesYt+6C7dWc1XsZhEFVQhahzFdAWNIy9O1 vz1rQsVt5uAhpdlZv/S8QjsOY0iAg5T9AlJIKIYg3WPZDbQyOltvIFtpLbS+UgtRneZd 7LRQ== X-Received: by 10.107.3.163 with SMTP id e35mr37013753ioi.157.1448538554508; Thu, 26 Nov 2015 03:49:14 -0800 (PST) In-Reply-To: <85lh9l9f6e.fsf_-_@benfinney.id.au> 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: , Xref: csiph.com comp.lang.python:99564 On Thu, Nov 26, 2015 at 10:24 PM, Ben Finney w= rote: > Dave Farrance writes: > >> Marko Rauhamaa wrote: >> >> >Dave Farrance : >> > >> >> (Conversely, I see that unlike CPython, all PyPy's numbers have >> >> unchanging ids, even after exiting PyPy and restarting, so it seems >> >> that PyPy's numerical ids are "faked".) >> > >> >What's a faked id? >> >> You can figure out what I'm getting at -- i.e. I presume that the ids >> are not pointers to stored numbers in memory (as with CPython) but are >> a translation of the numerical variable's value. > > Why refer to that as =E2=80=9Cfaked=E2=80=9D? That's what I can't figure = out about what > you're getting at. Perhaps Marko shares my uncomprehension. > > The Python language makes no promise about =E2=80=9Cpointers to stored nu= mbers > in memory=E2=80=9D for object identity. That is an implementation detail = of > CPython, and is *explicitly* not promised for any other Python > implementation. > > If you are surprised that object identity appears to have no connection > with memory location, then you've made unwarranted assumptions that are > explicitly warned against in the Python documentation. I can't remember which language it was (maybe Lua?), but I know there's one that uses a machine word to store either a pointer to a heap object, or an integer of at most one less bit than the machine word, represented by 2*n+1. A system like this would work for Python object IDs; it guarantees that all heap objects have unique even IDs (because no two can share the same address; all it takes is requiring 16-bit alignment, and most modern CPUs will give at least 32-bit), and all small integers will be slotted in between them. So the integer objects might themselves be entirely faked, never actually existing in memory, yet never violating the rule of object IDs. (Any integer too big to fit in a machine word minus one bit would be heap-allocated, so they're safe.) That's "faked", in a sense, but still perfectly compliant. ChrisA