Memory layout of record arrays
Hello, I've been using record arrays to create arrays with different types and since I'm doing a lot of computation on each of the different fields, the default memory layout does not serve my computations. Ideally, I would like to have record arrays where each field is a contiguous block of memory. I searched the dtype documentation but did not find anything about it. In the meantime, I wrote a class that emulates this behavior, but it does not inherit from nd.array and I need inheritance. To sum up, I would like to have:
Z = np.zeros(3, dtype=[('x',np.float32), ('y',np.int)])
print Z['x'].flags[['C_CONTIGUOUS']
False <= should be True
print Z['y'].flags[['C_CONTIGUOUS']
False <= should be True
Z.shape == Z['x'].shape == Z['y'].shape
True Is there any obvious solution that I missed ? Nicolas
participants (2)
-
David Cournapeau
-
Nicolas Rougier