Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28497

Re: is implemented with id ?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'true,': 0.04; 'expressions': 0.07; 'python': 0.09; 'expression:': 0.09; 'cc:addr :python-list': 0.10; 'language': 0.14; 'benjamin': 0.16; 'executed.': 0.16; 'expressions,': 0.16; 'int.': 0.16; 'integers,': 0.16; 'integers.': 0.16; 'said.': 0.16; 'true:': 0.16; 'valid.': 0.16; 'wrote:': 0.17; 'pointed': 0.17; 'specify': 0.17; 'string,': 0.17; 'thanks,': 0.18; 'all,': 0.21; 'object.': 0.22; 'cc:2**0': 0.23; 'statement': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'no,': 0.29; 'subject: ?': 0.30; 'not.': 0.32; 'could': 0.32; 'thanks': 0.34; 'but': 0.36; 'compare': 0.36; 'anything': 0.36; 'subject:with': 0.36; 'should': 0.36; 'address.': 0.36; 'does': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'object': 0.38; 'some': 0.38; 'nothing': 0.38; 'sure': 0.38; 'delete': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'your': 0.60; 'matter': 0.61; 'share': 0.61; 'evaluate': 0.62; 'header:Reply- To:1': 0.68; 'physical': 0.69; 'received:74.208': 0.71; 'reply- to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'risking': 0.84; 'hand,': 0.97
Date Wed, 05 Sep 2012 10:00:09 -0400
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0
MIME-Version 1.0
To Franck Ditter <franck@ditter.org>
Subject Re: is implemented with id ?
References <franck-9EED34.08303005092012@news.free.fr> <mailman.213.1346827305.27098.python-list@python.org> <franck-053A38.15194605092012@news.free.fr>
In-Reply-To <franck-053A38.15194605092012@news.free.fr>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:aILnumty78pjsFPxFG5Frkx96adTdd3knC8B7G+pR9m BEPbwAHV4G5pHcSIGKrtoSX8uqZuAmpYuosGFhI2xKo9I/4SsZ lhthaalk0lCHQnddt9sLy4Z0IdlZXJPlmKNzbNBWfMj9JwPkW1 ZqIYUIrkojl5Jja3dqeFwG0O6N2XCi1EJJgm0J3wKVfJ7edqxA JrK2GMwsPuiv7GKZnKdZ8gfS1dnTKey2AT/j86Y7xOYhsM8sty 1Ae6yzxLSJoO/Y+Ea/WRuUza3h8a/tzqLAZNStfgaqiMpy2aMo NYMMGC6T2c05PNodIGtfJ/L9pgvJtrtVHvYQeTD3RF7ErRFug= =
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.239.1346853638.27098.python-list@python.org> (permalink)
Lines 36
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346853638 news.xs4all.nl 6972 [2001:888:2000:d::a6]:40697
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28497

Show key headers only | View raw


Please don't top-post.  Now your message is out of order, and if I have
to delete the part Benjamin said.

On 09/05/2012 09:19 AM, Franck Ditter wrote:
> Thanks to all, but :
> - I should have said that I work with Python 3. Does that matter ?
> - May I reformulate the queston : "a is b" and "id(a) == id(b)"
>   both mean : "a et b share the same physical address". Is that True ?
> Thanks,

No, id() has nothing to do with physical address.  The Python language
does not specify anything about physical addresses.  Some
implementations may happen to use physical addresses, others arbitrary
integers.  And they may reuse such integers, or not.  Up to the
implementation.

And as others have pointed out, when you compare two id's, you're
risking that one of them may no longer be valid.  For example, the
following expression:

     flag = id(func1()) == id(func2())

could very well evaluate to True, even if func1() always returns a
string, and func2() always returns an int.  On the other hand, the 'is'
expression makes sure the two expressions are bound to the same object.

If a and b are simple names, and not placeholders for arbitrary
expressions, then I  THINK  the following would be true:

"a is b"  and   "id(a) == id(b)"  both mean that the names a and b are
bound to the same object at the time the statement is executed.

-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

is implemented with id ? Franck Ditter <franck@ditter.org> - 2012-09-05 08:30 +0200
  Re: is implemented with id ? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2012-09-04 23:40 -0700
    Re: is implemented with id ? Franck Ditter <franck@ditter.org> - 2012-09-05 15:19 +0200
      Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-09-05 15:48 +0200
        Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 12:41 -0700
          Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-11-03 22:49 +0100
            Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-03 22:18 +0000
              Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-11-04 09:50 +1100
              Re: is implemented with id ? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-11-04 01:14 +0000
                Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-04 03:10 +0000
                Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-11-04 14:19 +1100
                Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 22:09 -0700
                Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-11-04 11:13 +0100
              Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-11-04 12:22 +1100
              Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 22:08 -0700
            Re: is implemented with id ? Roy Smith <roy@panix.com> - 2012-11-03 18:41 -0400
            Re: is implemented with id ? aahz@pythoncraft.com (Aahz) - 2012-11-03 22:12 -0700
      Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 10:00 -0400
        Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 14:41 +0000
          Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 11:09 -0400
            Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 15:36 +0000
            Re: is implemented with id ? Hans Mulder <hansmu@xs4all.nl> - 2012-09-05 18:47 +0200
              Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 13:19 -0400
          Re: is implemented with id ? Terry Reedy <tjreedy@udel.edu> - 2012-09-05 14:31 -0400
          Re: is implemented with id ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-05 22:08 -0400
          Re: is implemented with id ? Duncan Booth <duncan.booth@invalid.invalid> - 2012-09-06 09:34 +0000
            Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-09-06 19:50 +1000
          Re: is implemented with id ? 88888 Dihedral <dihedral88888@googlemail.com> - 2012-11-04 01:33 -0700
  Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 09:14 +0000
    Re: is implemented with id ? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-05 05:48 -0700
      Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 09:46 -0400
      Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-05 14:13 +0000
        Re: is implemented with id ? Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-05 11:08 -0600
        Re: is implemented with id ? Chris Angelico <rosuav@gmail.com> - 2012-09-06 19:07 +1000
      Re: is implemented with id ? Terry Reedy <tjreedy@udel.edu> - 2012-09-05 14:27 -0400
        Re: is implemented with id ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-06 06:44 +0000
          Re: is implemented with id ? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-06 01:24 -0700
          Re: is implemented with id ? Roy Smith <roy@panix.com> - 2012-09-06 08:16 -0400
            Re: is implemented with id ? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-06 06:30 -0700
      Re: is implemented with id ? Dave Angel <d@davea.name> - 2012-09-05 14:40 -0400

csiph-web