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.
This commit is contained in:
Fred Drake 2001-12-03 18:27:22 +00:00
parent cee949f945
commit 1722e4a952
1 changed files with 24 additions and 30 deletions

View File

@ -4,8 +4,9 @@ Memory-mapped file support}
\declaremodule{builtin}{mmap} \declaremodule{builtin}{mmap}
\modulesynopsis{Interface to memory-mapped files for \UNIX\ and Windows.} \modulesynopsis{Interface to memory-mapped files for \UNIX\ and Windows.}
Memory-mapped file objects behave like both mutable strings and like Memory-mapped file objects behave like both strings and like
file objects. You can use mmap objects in most places where strings 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 are expected; for example, you can use the \module{re} module to
search through a memory-mapped file. Since they're mutable, you can search through a memory-mapped file. Since they're mutable, you can
change a single character by doing \code{obj[\var{index}] = 'a'}, or 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 \function{os.open()} function, which returns a file descriptor
directly (the file still needs to be closed when done). 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}}} \begin{funcdesc}{mmap}{fileno, length\optional{, tagname\optional{, access}}}
\strong{(Windows version)} Maps \var{length} bytes from the file \strong{(Windows version)} Maps \var{length} bytes from the file
specified by the file handle \var{fileno}, and returns a mmap 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 mapping is created without a name. Avoiding the use of the tag
parameter will assist in keeping your code portable between \UNIX{} parameter will assist in keeping your code portable between \UNIX{}
and Windows. 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} \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 \strong{(\UNIX{} version)} Maps \var{length} bytes from the file
specified by the file descriptor \var{fileno}, and returns a mmap specified by the file descriptor \var{fileno}, and returns a mmap
object. 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}. written. \var{prot} defaults to \constant{PROT_READ | PROT_WRITE}.
\var{access} may be specified in lieu of \var{flags} and \var{prot} \var{access} may be specified in lieu of \var{flags} and \var{prot}
as an optional keyword parameter. \var{access} accepts one of three as an optional keyword parameter. It is an error to specify both
values: \constant{ACCESS_READ}, \constant{ACCESS_WRITE}, or \var{flags}, \var{prot} and \var{access}. See the description of
\constant{ACCESS_COPY} to specify readonly, write-through, or \var{access} above for information on how to use this parameter.
copy-on-write memory respectively. \var{access} can be used on both \end{funcdescni}
\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}
Memory-mapped file objects support the following methods: Memory-mapped file objects support the following methods: