I got a C library storing its results in memory as a structure of arrays and returning a pointer to it. I'd like to create a writeable numpy array using this memory. Unfortunately, the arrays don't have a common type making this rather difficult.
For a classic array of structures, I'd create a equivalent ctypes Structure, init it via from_address() and pass that to numpy.ctypeslib.as_array(). Doing this with a structure of array results in a zero dimensional array, meaning I can't slice it.
Since this basically is just column major instead of row major layout, I hoped that I could just pass a F_CONTINOUS flag to as_array, but it does not have that option. I looked into NumPy's array interface protocol and to me it seems that this use case is not supported, as I can't provide strides for descr.
Is there a way to create a structured array in column-major order or do I need to create a separate array for each column?
I only found one similar question, but in the answer it was only suggested that it may work with advanced dtypes, which I couldn't confirm.