[Python-Dev] mmapfile module

Andrew M. Kuchling akuchlin@mems-exchange.org
Thu, 30 Mar 2000 15:22:02 -0500 (EST)


Guido van Rossum writes:
>I don't know enough about this, but it seems that there might be two
>steps: *creating* a mmap object is necessarily platform-specific; but
>*using* a mmap object could be platform-neutral.
>
>What is the API for mmap objects?

You create them; Unix wants a file descriptor, and Windows wants a
filename.  Then they behave like buffer objects, like mutable strings.

I like Fredrik's suggestion of an 'open(filename, mode, ...)' type of
interface.  If someone can suggest a way to handle the extra flags
such as MAP_SHARED and the Windows tag argument, I'll happily
implement it.  Maybe just keyword arguments that differ across
platforms?  open(filename, mode, [tag = 'foo',] [flags =
mmapfile.MAP_SHARED]).  We could preserve the ability to mmap() only a
file descriptor on Unix through a separate openfd() function.  I'm
also strongly tempted to rename the module from mmapfile to just
'mmap'.

I'd suggest waiting until the interface is finalized before adding the
module to the CVS tree -- which means after 1.6a1 -- but I can add the
module as it stands if you like.  Guido, let me know if you want me to
do that.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
A Puck is harder by far to hurt than some little lord of malice from the lands
of ice and snow. We Pucks are old and hard and wild...
  -- Robin Goodfellow, in SANDMAN #66: "The Kindly Ones:10"