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 pass the address of an object to 
ctypes is to use that id. Is that intentional?

As I see it, there is a conflict between two facts:

- that id() returns a memory address is an implementation detail; as 
such users should not rely on it, as the implementation could (in 
principle) change without notice;

- but users using ctypes have no choice but to rely on id() returning 
the object memory address, as of it were an offical part of the API.

Implementations like PyPy which emulate ctypes, while objects don't have 
fixed memory locations, will surely have a problem here. I don't know 
how PyPy solves this.

Have I misunderstood something here?



-- 
Steve
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
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