Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28497
| Date | 2012-09-05 10:00 -0400 |
|---|---|
| From | Dave Angel <d@davea.name> |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.239.1346853638.27098.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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