On 28 Mar 2005 15:00:37 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hello, > > 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? > > -SB > > -- > http://mail.python.org/mailman/listinfo/python-list >
http://docs.python.org/lib/module-mmap.html 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 index: >>> buffers = (buffer_1, buffer_2) >>> do_something_to(buffers[0]) >>> do_something_else_with(buffers[1]) 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. -- Sean Blakey Saint of Mild Amusement, Evil Genius, Big Geek Python/Java/C++/C(Unix/Windows/Palm/Web) developer quine = ['print "quine =",quine,"; exec(quine[0])"'] ; exec(quine[0]) -- http://mail.python.org/mailman/listinfo/python-list