On 24/01/2020 21:01, Terry Reedy wrote:
On 1/24/2020 7:09 AM, Steven D'Aprano wrote:
On Fri, Jan 24, 2020 at 05:45:35AM -0500, Terry Reedy wrote:
On 1/24/2020 3:36 AM, Victor Stinner wrote:
CPython current behavior rely on the fact that it's possible to get
the memory address of an object.
No, this behavior relies on the language specification that all objects
have temporally unique integer ids that can be compared with 'is'.
In particular, Jython and IronPython have to implement Python's 'id'
and 'is'. I believe 'id' is a bit of a nuisance. One way is a
permanent index into a list of mutable addresses. Once 'id' is done,
'is' should be easy.
Just for interest, in Jython, making id() an integer is enough of a
nuisance that we don't invent an answer unless you ask for one. It
involves a custom weak map from the abstract (Java) identity to integers
allocated one up.
"is" is relatively easy (with bit of delicacy about proxies to the same
Java object), and is based on Java ==. It is not implemented using id(),
but behaves as if it might be. The statement "An Object’s identity is
determined using the |id()| function" is a little misleading but it is
difficult to express the abstract concept of object identity.
Jeff Allen
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/65JITJFSG2MU4624N4TE4DMZJ4H6GEKO/
Code of Conduct: http://python.org/psf/codeofconduct/