Python mmap Module
Example
Create an in-memory anonymous map, write and read bytes (no files needed):
import mmap
m = mmap.mmap(-1, 8)
m.write(b"Linus")
m.seek(0)
print(m.read(5))
Try it Yourself »
Definition and Usage
The mmap module provides memory-mapped file support, exposing file contents directly in memory.
Use it for efficient random access to large files or to share memory between processes (platform-dependent).
Members
Member | Description |
---|---|
mmap() | Create a new memory-map to a file or anonymous memory. |
ACCESS_READ | Open the mapping with read-only access. |
ACCESS_WRITE | Open the mapping with write-through access. |
ACCESS_COPY | Open the mapping with copy-on-write access. |