mmap only supports string
robert.kern at gmail.com
Thu Jan 8 21:51:45 CET 2009
Neal Becker 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.
You could use numpy as an intermediate. Slices will be numpy arrays which are
views onto the mmap (no memory copying), and you can get a buffer from the numpy
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list