[Numpy-discussion] How to find number of bytes in a PyArrayObject without a segfault
Alex Eftimiades
alexeftimiades at gmail.com
Thu Sep 12 21:09:12 EDT 2013
I ultimately want to access the total number of bytes in a
PyArrayObject through a C++ program. I cannot seem to do it without
sefaulting. All of the following yields a segfault:
my_array->descr->subarray->shape
my_array->dimensions
PyArray_SHAPE(my_array)
PyArray_DIMS(my_array)
PyArray_ITEMSIZE(my_array)
and of course...
PyArray_NBYTES(my_array)
I am working from within sage if that makes any difference. Is there a
way to iterate over an array from within C++ without knowing the
number of bytes in the array (and using strides--which oddly enough do
not result in a segfault), or iterating over each dimension?
Please point me in the right direction. There must be a way or else
the entire software suite would not work.
Thanks,
Alex Eftimiades
More information about the NumPy-Discussion
mailing list