[Cython] MemoryViews require writeable arrays?
Sturla Molden
sturla at molden.no
Thu Feb 28 16:41:27 CET 2013
On 28.02.2013 15:55, Dave Hirschfeld wrote:
> So the issue is that at present memoryviews can't be readonly?
https://github.com/cython/cython/blob/master/Cython/Compiler/MemoryView.py#L33
Typed memoryviews are thus acquired with the PyBUF_WRITEABLE flag. If
the the assigned buffer is readonly, the request to acquire the PEP3118
buffer will fail.
If you remove the PyBUF_WRITEABLE flag from lines 33 to 36, you can
acquire a readonly buffer with typed memoryviews. But this is not
recommended. In this case you would have to check for the readonly flag
yourself and make sure you don't write to readonly buffer.
Sturla
More information about the cython-devel
mailing list