Name
mmap
Synopsis
mmap(filedesc,length,tagname='') # Windows mmap(filedesc,length,flags=MAP_SHARED,prot=PROT_READ|PROT_WRITE) # Unix
Creates and returns an mmap object
m that maps into memory the first
length bytes of the file indicated by file
descriptor filedesc.
filedesc must normally be a file
descriptor opened for both reading and writing (except, on Unix-like
platforms, when argument prot requests
only reading or only writing). File descriptors are covered in Section 10.2.8. To get an mmap object
m that refers to a Python file object
f, use
m
=mmap.mmap(
f
.fileno( ),length
).
On Windows only, you can pass a
string tagname to give an explicit tag
name for the memory mapping. This tag name lets you have several
memory mappings on the same file, but this functionality is rarely
necessary. Calling mmap with only two arguments
has the advantage of keeping your code portable between Windows and
Unix-like platforms. On Windows, all memory mappings are readable and
writable and shared between processes, so that all processes with a
memory mapping on a file can see changes made by each such process.
On Unix-like platforms only, you can
pass mmap.MAP_PRIVATE as the
flags argument to get a mapping that is
private to your process and copy-on-write.
mmap.MAP_SHARED, the default, gets a mapping that
is shared with other processes, so that all processes mapping the
file can see changes made by one process (same as on Windows). You
can pass mmap.PROT_READ as the
prot argument to get a mapping ...