[Cython] MemoryViews require writeable arrays?
Sturla Molden
sturla at molden.no
Thu Feb 28 14:29:59 CET 2013
On 27.02.2013 20:05, Dave Hirschfeld wrote:
> Is this a required restriction? Is there any workaround?
http://www.python.org/dev/peps/pep-3118/
What you should consider is the "readonly" field in "struct bufferinfo"
or the access flag "PyBUF_WRITEABLE".
In short:
A PEP3118 buffer can be readonly, and then you shouldn't write to it!
When you set the readonly flag, Cython cannot retrieve the buffer with
PyBUF_WRITEABLE. Thus, Cython helps you not to shoot yourself in the
foot. I don't think you can declare a read-only memoryview in Cython.
(Well, not by any means I know of.)
Sturla
More information about the cython-devel
mailing list