Is it possible to get the value of pointer to raw data of ctypes.Structure instance in Python C extension? I would like to access and copy data from/to the instance of this class without bothering the interpreter by importing and using ctypes.memmove or ctypes.addressof. In other words, does ctypes provide any C API which I can use directly?
Is it possible to get the value of pointer to raw data of ctypes.Structure
Share
It doesn’t appear that ctypes exposes a C API.
This is how it’s done in >= 2.7: http://docs.python.org/extending/extending.html#providing-a-c-api-for-an-extension-module
ctypes source tagged at 2.7.1: http://svn.python.org/view/python/tags/r271/Modules/_ctypes/
I don’t see anywhere in the source where an API capsule is built. You’ll have to use the ctypes Python interface via the Python C API instead.