-
Python library : mmap
Memory-mapped file objects behave like both bytearray and like file objects. You can use mmap objects in most places where bytearray are expected:
- you can use the
re
module to search through a memory-mapped file - you can change a single byte by doing
obj[index] = 97
- you can change a subsequence by assigning to a slice :
obj[i_1:i_2] = b"..."
- you can read and write data starting at the current file position and
seek()
through the file to different positions
A memory-mapped file is created by the
mmap
constructor, chich is different on Unix and on Windows. In either case you must provide a file descriptor for a file opened for update.If you wi
- you can use the
理解Python中mmap : memory-mapped file
最新推荐文章于 2024-09-20 21:37:48 发布