is implemented with id ?
Hans Mulder
hansmu at xs4all.nl
Wed Sep 5 09:48:18 EDT 2012
More information about the Python-list mailing list
Wed Sep 5 09:48:18 EDT 2012
- Previous message (by thread): is implemented with id ?
- Next message (by thread): is implemented with id ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 5/09/12 15:19:47, 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 ? Yes. Keep in mind, though, that in some implementation (e.g. Jython), the physical address may change during the life time of an object. It's usually phrased as "a and b are the same object". If the object is mutable, then changing a will also change b. If a and b aren't mutable, then it doesn't really matter whether they share a physical address. Keep in mind that physical addresses can be reused when an object is destroyed. For example, in my Python3, id(math.sqrt(17)) == id(math.cos(17)) returns True, even though the floats involved are different, because the flaots have non-overlapping lifetimes and the physical address happens to be reused. Hope this helps, -- HansM
- Previous message (by thread): is implemented with id ?
- Next message (by thread): is implemented with id ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list