mmap only supports string

N

Neal Becker

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.
 
A

Aaron Brady

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top