I have a python memoryview pointing to a bytes object on which I would like to perform some processing in cython.
My problem is:
- because the
bytesobject is not writable, cython does not allow constructing a typed (cython) memoryview from it - I cannot use pointers either because I cannot get a pointer to the memoryview start
Example:
In python:
array = memoryview(b'abcdef')[3:]
In cython:
cdef char * my_ptr = &array[0]fails to compile with the message:Cannot take address of Python variablecdef char[:] my_view = arrayfails at runtime with the message:BufferError: memoryview: underlying buffer is not writable
How does one solve this?