Can someone advise me what the current correct way of accessing numpy pointers is?
My current code uses PyArray_Data(array), which seems to work fine but I understand is now deprecated.
Py_Array_DATA
Memoryview seems to be the preferred option. Can someone confirm this? Also, are memoryviews just pointers?
when I try to use the Windows SDK compiler, I get a compile fail - presumably because the relevant macros are not being imported as NPY_NO_DEPRECATED_API is not set correctly (should that be set or not set to allow the code to compile?).
Cheers,
Henry
--
--- You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Can someone advise me what the current correct way of accessing numpy pointers is?
My current code uses PyArray_Data(array), which seems to work fine but I understand is now deprecated.
According to Sturla:Py_Array_DATA
Is the new, non-depricated method ( is that the same ?). What's depricated is accessing the .data field of the ndarray struct.
But using a memory view is a more flexible option, as it can be built from any PEP 3118 buffer.
Memoryview seems to be the preferred option. Can someone confirm this? Also, are memoryviews just pointers?
&a_memview[0] is the pointer to the beginning of the buffer, so you can use that. But why not take advantage of memoryview features if you have one?
when I try to use the Windows SDK compiler, I get a compile fail - presumably because the relevant macros are not being imported as NPY_NO_DEPRECATED_API is not set correctly (should that be set or not set to allow the code to compile?).
What versions are you using? This works for me, though with warnings...