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

2019-01-17 Thread Steve Dower
I feel like I should clarify - not everyone who posted got it wrong, and I understand there's a side discussion among those who are also interested/participants in https://discuss.python.org/t/demoting-the-is-operator-to-avoid-an-identity-crisis/86/ - but there was no of acknowledgement of Eryk

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

2019-01-17 Thread Steve Dower
For everyone who managed to reply *hours* after Eryk Sun posted the correct answer and still get it wrong, here it is again in full. As a bonus, here's a link to the place where this answer appears in the documentation: https://docs.python.org/3/library/ctypes.html#ctypes.py_object Cheers, Steve

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

2019-01-17 Thread Nathaniel Smith
n Thu, Jan 17, 2019 at 4:51 PM Gregory P. Smith wrote: > > I've heard that libraries using ctypes, cffi, or cython code of various sorts > in the real world wild today does abuse the unfortunate side effect of > CPython's implementation of id(). I don't have specific instances of this in >

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

2019-01-17 Thread MRAB
On 2019-01-18 00:48, Gregory P. Smith wrote: I've heard that libraries using ctypes, cffi, or cython code of various sorts in the real world wild today does abuse the unfortunate side effect of CPython's implementation of id(). I don't have specific instances of this in mind but trust what

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

2019-01-17 Thread Chris Angelico
On Fri, Jan 18, 2019 at 11:50 AM Gregory P. Smith wrote: > > I've heard that libraries using ctypes, cffi, or cython code of various sorts > in the real world wild today does abuse the unfortunate side effect of > CPython's implementation of id(). I don't have specific instances of this in >

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

2019-01-17 Thread Gregory P. Smith
I've heard that libraries using ctypes, cffi, or cython code of various sorts in the real world wild today does abuse the unfortunate side effect of CPython's implementation of id(). I don't have specific instances of this in mind but trust what I've heard: that it is happening. id() should never

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

2019-01-17 Thread eryk sun
On 1/17/19, Steven D'Aprano wrote: > > I understand that the only way to pass the address of an object to > ctypes is to use that id. Is that intentional? It's kind of dangerous to pass an object to C without an increment of its reference count. The proper way is to use a simple pointer of type

Re: [Python-Dev] pickle5 backport updated

2019-01-17 Thread Nick Coghlan
On Wed, 16 Jan 2019 at 20:38, Antoine Pitrou wrote: > > On Wed, 16 Jan 2019 11:25:04 +0100 > Victor Stinner wrote: > > I see that the PEP is still a draft. What's the status? > > PEP 574 is ready for pronouncement. It's waiting for an authority to > approve it (or decide on a PEP delegate, who

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

2019-01-17 Thread Antoine Pitrou
On Thu, 17 Jan 2019 21:26:06 +1100 Steven D'Aprano wrote: > Disclaimer: I'm not a ctypes expert, so I might have this completely > wrong. If so, I apologise for the noise. > > The id() function is documented as returning an abstract ID number. In > CPython, that happens to have been

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

2019-01-17 Thread Steven D'Aprano
Disclaimer: I'm not a ctypes expert, so I might have this completely wrong. If so, I apologise for the noise. The id() function is documented as returning an abstract ID number. In CPython, that happens to have been implemented as the address of the object. I understand that the only way to