pythonista at gmail.com
Tue Mar 29 01:20:41 CEST 2005
On 28 Mar 2005 15:00:37 -0800, shama.bell at gmail.com
<shama.bell at gmail.com> wrote:
> How do i create two memory mapped buffers(mmap) and pass an index to
> select which one needs to be populated?
> Is it possible to define the size of the buffer?
I haven't tried it, but it should be pretty straightforward to create
two mmaped buffers.
Step 1: Import the mmap module.
Step 2: Create or find the file you want to map. Open it, and get the
fileno. Call mmap.mmap, passing the fileno and buffer size.
Repeat Step 2 with a different file to create a second mmaped buffer.
I'm not sure what you mean by "and pass an index to select which one
needs to be populated". If you pack the buffers into a
tuple/list/other sequence object, it should be easy to access them by
>>> buffers = (buffer_1, buffer_2)
To mmap buffers, you MUST define the size.
I'm sorry I can't be more helpful; perhaps if you gave a higher-level
description of what you are trying to accomplish, I could give better
pointers in the right direction.
Saint of Mild Amusement, Evil Genius, Big Geek
quine = ['print "quine =",quine,"; exec(quine)"'] ; exec(quine)
More information about the Python-list