IdentifiantMot de passe
Mot de passe oublié ?Je m'inscris ! (gratuit)
22.1 Introduction

22.1 Introduction

numarray provides support for the creation of arrays which are mapped directly onto files with the numarray.memmap module. Much of numarray's design, the ability to handle misaligned and byteswapped arrays for instance, was motivated by the desire to create arrays from portable files which contain binary array data. One advantage of memory mapping is efficient random access to small regions of a large file: only the region of the mapped file which is actually used in array operations needs to be paged into system memory; the rest of the file remains unread and unwritten.

numarray.memmap is pure Python and is layered on top of Python's mmap module. The basic idea behind numarray's memory mapping is to create a ``buffer'' referring to a region in a mapped file and to use it as the data store for an array. The numarray.memmap module contains two classes, one which corresponds to an entire mapped file (Memmap) and one which corresponds to a contiguous region within a file (MemmapSlice). MemmapSlice objects have these properties:

  • MemmapSlices can be used as NumArray buffers.
  • MemmapSlices are non-overlapping.
  • MemmapSlices are resizable.
  • Changing the size of a MemmapSlice changes the parent Memmap.

Send comments to the NumArray community.