ffi.buffer is great to get read/write access to a chunk of C memory from Python, but something is needed the other way around.
cffi should have a
ffi.from_buffer(ctype, obj) method that would accept any object that supports the buffer protocol and return a cdata that holds a reference to
obj and points to the same data.
obj is read-only, maybe
from_buffer could only allow creating cdata of a "const" type (though I don’t know if "const" means anything to cffi.)
I would use this to implement ImageSurface.create_for_data in cairocffi, so that a cairo image could share memory with a bytearray or a numpypy array.