Direct use of bytearray buffers with ctypes ?

Pakal chambon.pascal at gmail.com
Sat Jan 9 12:25:06 EST 2010


Hello

I'm having big trouble wrapping the win32 ReadFile() function with
ctypes.

I wanted to allow the user to give a bytearray to this function, so
that the writable buffer of this bytearray is directly used to receive
the data from the file ; thus, no temporary copy in a separate ctype
buffer would be required.

However, I've found no way to provide ReadFile with a pointer to the
inner buffer of the bytearray object. I get misc. TypeErrors and
ValueErrors all the time, by trying to use the from_buffer() method or
other ctypes functions.

Is that actually posisble to expose with ctypes the internals of a
python object to the system, or is that unsupported at the moment ?



More information about the Python-list mailing list