Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions Doc/library/mmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ still needs to be closed when done).
mapping.

For both the Unix and Windows versions of the constructor, *access* may be
specified as an optional keyword parameter. *access* accepts one of three
values: :const:`ACCESS_READ`, :const:`ACCESS_WRITE`, or :const:`ACCESS_COPY`
to specify read-only, write-through or copy-on-write memory respectively.
*access* can be used on both Unix and Windows. If *access* is not specified,
Windows mmap returns a write-through mapping. The initial memory values for
all three access types are taken from the specified file. Assignment to an
:const:`ACCESS_READ` memory map raises a :exc:`TypeError` exception.
Assignment to an :const:`ACCESS_WRITE` memory map affects both memory and the
underlying file. Assignment to an :const:`ACCESS_COPY` memory map affects
memory but does not update the underlying file.
specified as an optional keyword parameter. *access* accepts one of four
values: :const:`ACCESS_READ`, :const:`ACCESS_WRITE`, or :const:`ACCESS_COPY` to
specify read-only, write-through or copy-on-write memory respectively, or
:const:`ACCESS_DEFAULT` to defer to *prot*. *access* can be used on both Unix
and Windows. If *access* is not specified, Windows mmap returns a
write-through mapping. The initial memory values for all three access types
are taken from the specified file. Assignment to an :const:`ACCESS_READ`
memory map raises a :exc:`TypeError` exception. Assignment to an
:const:`ACCESS_WRITE` memory map affects both memory and the underlying file.
Assignment to an :const:`ACCESS_COPY` memory map affects memory but does not
update the underlying file.

.. versionchanged:: 3.7
Added :const:`ACCESS_DEFAULT` constant.

To map anonymous memory, -1 should be passed as the fileno along with the length.

Expand Down
1 change: 1 addition & 0 deletions Misc/NEWS.d/next/Library/2017-10-23.bpo-31854.fh8334f.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``mmap.ACCESS_DEFAULT`` constant.
1 change: 1 addition & 0 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,7 @@ PyInit_mmap(void)

setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity());

setint(dict, "ACCESS_DEFAULT", ACCESS_DEFAULT);
setint(dict, "ACCESS_READ", ACCESS_READ);
setint(dict, "ACCESS_WRITE", ACCESS_WRITE);
setint(dict, "ACCESS_COPY", ACCESS_COPY);
Expand Down