mmap only supports string

Aaron Brady castironpi at gmail.com
Thu Jan 8 09:40:46 CET 2009


On Jan 7, 8:14 pm, Neal Becker <ndbeck... at gmail.com> wrote:
> Problem is, AFAIK a string can only be created as a copy of some other data.  Say I'd like to take some large object and read/write to/from mmap object.  A good way to do this would be the buffer protocol.  Unfortunately, mmap only supports string.  A string could only be created after copying the original object AFAIK.
>
> I think mmap should work directly with buffer protocol, so it could directly read/write with objects supporting buffer protocol.  Specifically, mmap slice should support buffer protocol.

Hi.  It is a weakness.  Strings are supposed to be read-only in
Python: so.  You can use and get the PyObject_AsWriteBuffer C function
from 'ctypes' if you are interested.



More information about the Python-list mailing list