pydoc > mmap

πŸ“„ NAME

mmap

πŸš€ Quick Reference

Use CaseCommandDescription
Create a memory‑mapped file mmap.mmap(fileno, length) Maps a file into memory for efficient I/O
Read bytes m.read(10) Read up to 10 bytes from the current position
Write bytes m.write(b'hello') Write bytes to the mapped memory
Find a pattern m.find(b'needle') Return index of first occurrence, or -1
Flush changes to disk m.flush() Ensure changes are written to the underlying file
Resize the mapping m.resize(newsize) Change the size of the memory mapping
Close the mapping m.close() Unmap memory and release resources

πŸ“š MODULE REFERENCE

https://docs.python.org/3.10/library/mmap.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

πŸ“¦ CLASSES

πŸ“„ mmap

πŸͺŸ Windows: mmap(fileno, length[, tagname[, access[, offset]]])
Maps length bytes from the file specified by the file handle fileno, and returns a mmap object. If length is larger than the current size of the file, the file is extended to contain length bytes. If length is 0, the maximum length of the map is the current size of the file, except that if the file is empty Windows raises an exception (you cannot create an empty mapping on Windows).

🐧 Unix: mmap(fileno, length[, flags[, prot[, access[, offset]]]])
Maps length bytes from the file specified by the file descriptor fileno, and returns a mmap object. If length is 0, the maximum length of the map will be the current size of the file when mmap is called. flags specifies the nature of the mapping. MAP_PRIVATE creates a private copy-on-write mapping, so changes to the contents of the mmap object will be private to this process, and MAP_SHARED creates a mapping that's shared with all other processes mapping the same areas of the file. The default value is MAP_SHARED.

πŸ•΅οΈ To map anonymous memory, pass -1 as the fileno (both versions).

πŸ“‹ Methods defined here

πŸ”§ Static methods defined here

πŸ“Œ Data descriptors defined here

πŸ“Š DATA

ACCESS_COPY = 3
ACCESS_DEFAULT = 0
ACCESS_READ = 1
ACCESS_WRITE = 2
ALLOCATIONGRANULARITY = 4096
MADV_DODUMP = 17
MADV_DOFORK = 11
MADV_DONTDUMP = 16
MADV_DONTFORK = 10
MADV_DONTNEED = 4
MADV_FREE = 8
MADV_HUGEPAGE = 14
MADV_HWPOISON = 100
MADV_MERGEABLE = 12
MADV_NOHUGEPAGE = 15
MADV_NORMAL = 0
MADV_RANDOM = 1
MADV_REMOVE = 9
MADV_SEQUENTIAL = 2
MADV_UNMERGEABLE = 13
MADV_WILLNEED = 3
MAP_ANON = 32
MAP_ANONYMOUS = 32
MAP_DENYWRITE = 2048
MAP_EXECUTABLE = 4096
MAP_POPULATE = 32768
MAP_PRIVATE = 2
MAP_SHARED = 1
PAGESIZE = 4096
PROT_EXEC = 4
PROT_READ = 1
PROT_WRITE = 2

πŸ“ FILE

/usr/lib/python3.10/lib-dynload/mmap.cpython-310-x86_64-linux-gnu.so

mmap
πŸ“„ NAME πŸš€ Quick Reference πŸ“š MODULE REFERENCE πŸ“¦ CLASSES
πŸ“„ mmap
πŸ“Š DATA πŸ“ FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 12:17 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^