mmap module and C extensions

Thomas Wouters thomas at xs4all.net
Sun Nov 5 09:38:44 EST 2000


On Sun, Nov 05, 2000 at 08:56:45AM +0000, Radovan Garabik wrote:

> I wrote an application in python, making heavy use of mmap module.
> All works well and nice, but now (for performance reasons) I'd
> like to move some functions into a separate C module.
> The problem is, how do I find out the pointer as returned
> by mmap(2) and make it available to my C module...

I don't believe that is currently supported (the mmap module is pretty new)
but I didn't do more than browse through the mmap module. You can do it if
you muck around in the internals of the mmap_object object, where the
pointer to the mmaped region is stored in the 'data' member. Unfortunately,
there doesn't seem to be a PyMMap_Check()-alike function to make sure you
have a mmap_object in your hands, so you could risk segmentation faults if
people pass in the wrong type of object.

(The mechanics of Python modules would make such functions difficult anyway,
since the symbols exposed by the mmapmodule might not be visible when your
module loads, but it isn't impossible. The 'embedding and extending' manual
shows a way to do it.)

You could see this as a bug, and submit a bugreport through SourceForge. If
people agree that it should be fixed, it might be coded by someone, or put
on the wishlist (PEP 42) until someone codes it. If you need it badly, you
could code it yourself, and contribute the code. (Python internals is pretty
easy to hack, especially something like the mmap module, which is pretty
straightforward.)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list