Memeplex added the comment:
I have been happily using this helper function:
def c_array(*args):
if type(args[1]) is int:
ptr, size = args
return (ptr._type_ * size).from_address(ct.addressof(ptr.contents))
else:
c_type, buf = args
return (c_type * (len(buf) // ct.sizeof(c_type))).from_buffer_copy(buf)
For example:
c_array(ptr_obj, 10)
c_array(c_int, bytes_obj)
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27274>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com