Re: [Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?

2019年1月18日 02:57:51 -0800

On 2019年1月18日 20:49:26 +1100
Steven D'Aprano <[email protected]> wrote:
> 
> Language-wise, I'm trying to get a definitive answer of whether or not 
> id() returning the address of the object should be a guaranteed feature 
> or not.
For me, the definitive answer is "yes, it's a CPython feature".
However, it's obviously not a PyPy feature, and I'm not sure about other
implementations. Anything with an object model that can eliminate
in-memory objects in favour of in-register values (for example using
tagged pointers or type specialization + lifetime analysis) is obviously
not able to hold the promise that id() returns the /address/ of the
"object".
That doesn't mean the CPython feature has to live forever. We may want
to deprecate it at some point (though it's not obvious how to warn the
user: just because you're using id() doesn't mean you're interested in
the actual /address/, rather than some arbitrary unique id).
> According to this claim, using id() to get the address for use in ctypes 
> is the correct and only way to do it
I don't know why you keep repeating that. You were already explained
that it's /not/ the correct and only way to get the address for use in
ctypes.
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to