I have a C function uint8_t *begin(); which returns a pointer to allocated memory.
Here is a ctypes binding to it:
begin = mylibrary.begin
begin.argtypes = ()
begin.restype = ctypes.POINTER(ctypes.c_uint8)
I need to fill memory with an array of the integers. Is there any quicker way to do it instead of this?
buffer = begin()
data = range(10)
for idx, value in enumerate(data):
buffer[idx] = ctypes.c_uint8(value)
It doesn't look to me, that iterating over the whole array is a very fast method, because that iterable data can contains a lot of items, millions of integers or something like this.