I am working on a Python C-extension code. Currently, a 1D C-array is converted to a Python List. Now I need to convert an ND-array, described by a 1) data type, 2) shape (as a 1D integer vector, for example, 2x4x3 array), and 3) data binary payload as serialized array elements of data-type.
I noticed that there is an array object in python: https://docs.python.org/2/library/array.html
I prefer to convert the ND array buffer to an array object instead of requiring installation of numpy ndarray - an additional dependency, but I failed to find any C-API to create/read/write Python-array objects from C.
does this interface (something similar to PyList_New) exist?
arrayclass is not multi-dimensional. But for interface the class offers abuffer protocol. Also switch to Py3 if you can. If you don't want to usenumpy, why the [numpy] tag?numpyorPILit doesn't look like you can do much; at least I'm not aware of any builtin packages that use attributes like shape and strides.array.arrayarrays will be useless to you, and the buffer API is mostly useful for C-level access, not for providing a Python interface.