[Python-Dev] ctypes: is it intentional that id() is the only way to get the address of an object?
Oh, bracket my brain glitch on small integers. Yes, they still give id()
of memory address, they just get reused, which is different. Nonetheless,
I never teach id(obj)
== ctypes.c_void_p.from_buffer(ctypes.py_object(b)).value ... and not only
because I only learned the latter spelling from eryk sun.
On Fri, Jan 18, 2019 at 10:29 AM David Mertz <mertz at gnosis.cx> wrote:
> On Fri, Jan 18, 2019, 5:55 AM Antoine Pitrou <solipsis at pitrou.net wrote:
>> > id() returning the address of the object should be a guaranteed feature
>> For me, the definitive answer is "yes, it's a CPython feature".
>> That doesn't mean the CPython feature has to live forever. We may want
>> to deprecate it at some point
> Whenever I've taught Python (quite a bit between writing, in person, and
> webinars), I have been very explicit in stating that id(obj) returns some
> unique number for each object, and mentioned that for MANY Python objects
> CPython users an implementation convenience of using the memory address.
> Every time I've explained it I've said not to rely on that implementation
> detail. It's not true for small integers, for example, even in CPython.
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...