[Numpy-discussion] memmap from fd?

Robert Kern robert.kern@gmail....
Sun Jan 11 20:45:39 CST 2009

On Sun, Jan 11, 2009 at 20:23, Neal Becker <ndbecker2@gmail.com> wrote:
> Robert Kern wrote:
> ....
>> That's a fair point. However, given the wider range of issues that you
>> had in trying to get memmap to work with your device, perhaps we
>> should just state that the memmap class is intended for the common use
>> case of regular files. The detection of the existing file size is
>> quite useful in that case. For special files where seek() et al. might
>> have different semantics, one should either subclass memmap to get the
>> behavior you need, or simply use frombuffer() or ndarray() on the mmap
>> object directly. The two reasons for the memmap class are the
>> auto-length-detection and tracking the lifetime of the open file. The
>> former you don't need (and can't do), and the latter isn't that hard
>> to do yourself.
>> Does that sound reasonable?
> Hmm.  frombuffer sounds nice, but python mmap doesn't expose buffer interface (I just added a feature request for this).  I suppose I could write my own mmap module.

Yeah, it does. Why do you think it doesn't? If it didn't work, the
memmap class wouldn't work.

> I couldn't find the reference to ndarray().  Any pointer?


The buffer= argument would be the mmap object. Basically, most of what
memmap.__new__() does is to set up the arguments for

Robert Kern

"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 Numpy-discussion mailing list