IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
22.8 Memmap methods


22.8 Memmap methods

A Memmap object represents an entire mapped file and is sliced to create objects which can be used as array buffers. It has these public methods:

close( )
close unites the Memmap and any RAM based slices with its underlying file and removes the mapping and all references to its slices. Once a Memmap has been closed, all of its slices become unusable.

find( string, offset=0)
find(string, offset=0) returns the first index at which string is found, or -1 on failure.
    >>> _open("memmap.tst","w+").write("this is a test")
    >>> Memmap("memmap.tst",len=14).find("is")
    2
    >>> Memmap("memmap.tst",len=14).find("is", 3)
    5
    >>> _open("memmap.tst","w+").write("x")
    >>> Memmap("memmap.tst",len=1).find("is")
    -1

insert( offset, size=None, buffer=None)
insert places a new slice at the specified offset of the Memmap. size indicates the length in bytes of the inserted slice when buffer is not specified. If buffer is specified, it should refer to an existing memory object created using numarray.memory.new_memory and size should not be specified.

flush( )
flush writes a Memmap out to its associated file, reconciling any inserted or resized slices by backing them directly on the map file rather than a system swap file. flush only makes sense for write and readwrite memory maps.

sync( )
sync forces slices which are backed on the map file to be immediately written to disk. Resized or newly inserted slices are not affected. sync only makes sense for write and readwrite memory maps.

Send comments to the NumArray community.