[Numpy-discussion] memmap from fd?

Neal Becker ndbecker2 at gmail.com
Fri Jan 9 08:26:00 EST 2009


Robert Kern wrote:

> On Fri, Jan 9, 2009 at 06:05, Neal Becker <ndbecker2 at gmail.com> wrote:
>> I'm working on interfacing to a custom FPGA board.  The kernel driver
>> exposes the FPGA memory via mmap.
>>
>> It might be nice to use numpy memmap to read/write data.  One issue is
>> that I think I will need to create the memmap array from a fd, not a file
>> name.  The reason is I wrote the driver to only allow 1 exclusive open,
>> and I already have it open for other reasons.  Any chance to create a
>> memmap array from a fd?
> 
> Use os.fdopen(fd) to create a file object which can be passed to the
> memmap constructor.
> 

Thanks!  I'm assuming in this case I can ignore comments about flushing the data to disk?

If an assignment to a slice of an memmap array will call mmap, there should be no need for any flushing.




More information about the NumPy-Discussion mailing list