diff options
author | Fred Drake <fdrake@acm.org> | 2001-12-03 18:27:22 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-12-03 18:27:22 (GMT) |
commit | 1722e4a95210afd6f47472fb903d082f2f964b8e (patch) | |
tree | bcc464703c68646d114c92e361bb31872ce843ca /Doc | |
parent | cee949f945eacf13b3d780624620f295c351886f (diff) | |
download | cpython-1722e4a95210afd6f47472fb903d082f2f964b8e.zip cpython-1722e4a95210afd6f47472fb903d082f2f964b8e.tar.gz cpython-1722e4a95210afd6f47472fb903d082f2f964b8e.tar.bz2 |
Re-word the intro slightly to avoid reader misunderstanding: strings are not
mutable! We do not want to shock anyone.
This closes SF bug #483805.
Re-factor so that the description of the "access" keyword parameter is not
repeated in both the descriptions of mmap(). Also, only make sure the first
description of mmap() appears in the index. The the index link is followed,
the first is now used to locate the page on the screen; chances are really good
both will be visible. This avoids the problem that the index entry for the
second is selected and the first version is not visible, making the reader
consider that mmap() is not available on Windows.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libmmap.tex | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/Doc/lib/libmmap.tex b/Doc/lib/libmmap.tex index 466dfcc..426f658 100644 --- a/Doc/lib/libmmap.tex +++ b/Doc/lib/libmmap.tex @@ -4,8 +4,9 @@ Memory-mapped file support} \declaremodule{builtin}{mmap} \modulesynopsis{Interface to memory-mapped files for \UNIX\ and Windows.} -Memory-mapped file objects behave like both mutable strings and like -file objects. You can use mmap objects in most places where strings +Memory-mapped file objects behave like both strings and like +file objects. Unlike normal string objects, however, these are +mutable. You can use mmap objects in most places where strings are expected; for example, you can use the \module{re} module to search through a memory-mapped file. Since they're mutable, you can change a single character by doing \code{obj[\var{index}] = 'a'}, or @@ -23,6 +24,21 @@ If you wish to map an existing Python file object, use its \function{os.open()} function, which returns a file descriptor directly (the file still needs to be closed when done). +For both the \UNIX{} and Windows versions of the function, +\var{access} may be specified as an optional keyword parameter. +\var{access} accepts one of three values: \constant{ACCESS_READ}, +\constant{ACCESS_WRITE}, or \constant{ACCESS_COPY} to specify +readonly, write-through or copy-on-write memory respectively. +\var{access} can be used on both \UNIX{} and Windows. If +\var{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 +\constant{ACCESS_READ} memory map raises a \exception{TypeError} +exception. Assignment to an \constant{ACCESS_WRITE} memory map +affects both memory and the underlying file. Assigment to an +\constant{ACCESS_COPY} memory map affects memory but does not update +the underlying file. + \begin{funcdesc}{mmap}{fileno, length\optional{, tagname\optional{, access}}} \strong{(Windows version)} Maps \var{length} bytes from the file specified by the file handle \var{fileno}, and returns a mmap @@ -38,23 +54,10 @@ directly (the file still needs to be closed when done). mapping is created without a name. Avoiding the use of the tag parameter will assist in keeping your code portable between \UNIX{} and Windows. - - \var{access} may be specified as an optional keyword parameter. - \var{access} accepts one of three values: \constant{ACCESS_READ}, - \constant{ACCESS_WRITE}, or \constant{ACCESS_COPY} to specify - readonly, write-through or copy-on-write memory respectively. - \var{access} can be used on both \UNIX{} and Windows. If - \var{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 - \constant{ACCESS_READ} memory map raises a \exception{TypeError} - exception. Assignment to an \constant{ACCESS_WRITE} memory map - affects both memory and the underlying file. Assigment to an - \constant{ACCESS_COPY} memory map affects memory but does not update - the underlying file. \end{funcdesc} -\begin{funcdesc}{mmap}{fileno, length\optional{, flags\optional{, prot\optional{, access}}}} +\begin{funcdescni}{mmap}{fileno, length\optional{, flags\optional{, + prot\optional{, access}}}} \strong{(\UNIX{} version)} Maps \var{length} bytes from the file specified by the file descriptor \var{fileno}, and returns a mmap object. @@ -72,19 +75,10 @@ directly (the file still needs to be closed when done). written. \var{prot} defaults to \constant{PROT_READ | PROT_WRITE}. \var{access} may be specified in lieu of \var{flags} and \var{prot} - as an optional keyword parameter. \var{access} accepts one of three - values: \constant{ACCESS_READ}, \constant{ACCESS_WRITE}, or - \constant{ACCESS_COPY} to specify readonly, write-through, or - copy-on-write memory respectively. \var{access} can be used on both - \UNIX{} and Windows. It is an error to specify both \var{flags}, - \var{prot} and \var{access}. The initial memory values for all - three access types are taken from the specified file. Assignment to - an \constant{ACCESS_READ} memory map raises a \exception{TypeError} - exception. Assignment to an \constant{ACCESS_WRITE} memory map - affects both memory and the underlying file. Assigment to an - \constant{ACCESS_COPY} memory map affects memory but does not update - the underlying file. -\end{funcdesc} + as an optional keyword parameter. It is an error to specify both + \var{flags}, \var{prot} and \var{access}. See the description of + \var{access} above for information on how to use this parameter. +\end{funcdescni} Memory-mapped file objects support the following methods: |