@@ -8,20 +8,21 @@ \section{\module{mmap} ---
88file objects. You can use mmap objects in most places where strings
99are expected; for example, you can use the \module {re} module to
1010search through a memory-mapped file. Since they're mutable, you can
11- change a single character by doing \code {obj[ \var {index} ] = 'a' }, or
11+ change a single character by doing \code {obj[\var {index}] = 'a' }, or
1212change a substring by assigning to a slice:
13- \code {obj[ \var {i1}:\var {i2} ] = '...' }. You can also read and write
13+ \code {obj[\var {i1}:\var {i2}] = '...' }. You can also read and write
1414data starting at the current file position, and \method {seek()}
1515through the file to different positions.
1616
1717A memory-mapped file is created by the following function, which is
1818different on Unix and on Windows.
1919
20- \begin {funcdesc }{mmap}{fileno, length \optional {, tagname} }
21- (Windows version) Maps \var {length} bytes from the file specified by
22- the file handle \var {fileno}, and returns a mmap object. If you wish
23- to map an existing Python file object, use its \method {fileno()}
24- method to obtain the correct value for the \var {fileno} parameter.
20+ \begin {funcdesc }{mmap}{fileno, length\optional {, tagname}}
21+ \strong {(Windows version)} Maps \var {length} bytes from the file
22+ specified by the file handle \var {fileno}, and returns a mmap object.
23+ If you wish to map an existing Python file object, use its
24+ \method {fileno()} method to obtain the correct value for the
25+ \var {fileno} parameter.
2526
2627\var {tagname}, if specified, is a string giving a tag name for the mapping.
2728Windows allows you to have many different mappings against the same
@@ -32,23 +33,24 @@ \section{\module{mmap} ---
3233and Windows.
3334\end {funcdesc }
3435
35- \begin {funcdesc }{mmap}{fileno, size \optional {, flags, prot}}
36- (Unix version) Maps \var {length} bytes from the file specified by the
37- file handle \var {fileno}, and returns a mmap object. If you wish to
38- map an existing Python file object, use its \method {fileno()} method
39- to obtain the correct value for the \var {fileno} parameter.
36+ \begin {funcdesc }{mmap}{fileno, size\optional {, flags, prot}}
37+ \strong {(Unix version)} Maps \var {length} bytes from the file
38+ specified by the file handle \var {fileno}, and returns a mmap object.
39+ If you wish to map an existing Python file object, use its
40+ \method {fileno()} method to obtain the correct value for the
41+ \var {fileno} parameter.
4042
4143\var {flags} specifies the nature of the mapping.
42- \code {MAP_PRIVATE} creates a private copy-on-write mapping, so
44+ \constant {MAP_PRIVATE} creates a private copy-on-write mapping, so
4345changes to the contents of the mmap object will be private to this
44- process, and \code {MAP_SHARED} creates a mapping that's shared
46+ process, and \constant {MAP_SHARED} creates a mapping that's shared
4547with all other processes mapping the same areas of the file.
46- The default value is \code {MAP_SHARED}.
48+ The default value is \constant {MAP_SHARED}.
4749
4850\var {prot}, if specified, gives the desired memory protection; the two
49- most useful values are \code {PROT_READ} and \code {PROT_WRITE}, to
50- specify that the pages may be read or written.
51- \var {prot} defaults to \code {PROT_READ | PROT_WRITE}.
51+ most useful values are \constant {PROT_READ} and \constant {PROT_WRITE},
52+ to specify that the pages may be read or written.
53+ \var {prot} defaults to \constant {PROT_READ | PROT_WRITE}.
5254\end {funcdesc }
5355
5456Memory-mapped file objects support the following methods:
@@ -59,13 +61,13 @@ \section{\module{mmap} ---
5961will result in an exception being raised.
6062\end {methoddesc }
6163
62- \begin {methoddesc }{find}{\var { string} \optional {, \var { start} }}
63- Returns the lowest index in the object where the substring \var {string} is
64- found. Returns \code {-1} on failure.
65- \var {start} is the index at which the search begins, and defaults to zero.
64+ \begin {methoddesc }{find}{string\optional {, start}}
65+ Returns the lowest index in the object where the substring
66+ \var {string} is found. Returns \code {-1} on failure. \var {start} is
67+ the index at which the search begins, and defaults to zero.
6668\end {methoddesc }
6769
68- \begin {methoddesc }{flush}{\optional {\var { offset}, \var { size} }}
70+ \begin {methoddesc }{flush}{\optional {offset, size}}
6971Flushes changes made to the in-memory copy of a file back to disk.
7072Without use of this call there is no guarantee that changes are
7173written back before the object is destroyed. If \var {offset} and
@@ -98,12 +100,11 @@ \section{\module{mmap} ---
98100\begin {methoddesc }{resize}{\var {newsize}}
99101\end {methoddesc }
100102
101- \begin {methoddesc }{seek}{\var {pos} \optional {, \var {whence}}}
102- Set the file's current position.
103- \var {whence} argument is optional and defaults to \code {0}
104- (absolute file positioning); other values are \code {1} (seek
105- relative to the current position) and \code {2} (seek relative to the
106- file's end).
103+ \begin {methoddesc }{seek}{pos\optional {, whence}}
104+ Set the file's current position.
105+ \var {whence} argument is optional and defaults to \code {0} (absolute
106+ file positioning); other values are \code {1} (seek relative to the
107+ current position) and \code {2} (seek relative to the file's end).
107108\end {methoddesc }
108109
109110\begin {methoddesc }{size}{}
@@ -122,8 +123,7 @@ \section{\module{mmap} ---
122123\end {methoddesc }
123124
124125\begin {methoddesc }{write_byte}{\var {byte}}
125- Write the single-character string \var {byte} into memory at the current position of
126- the file pointer; the file position is advanced by 1.
126+ Write the single-character string \var {byte} into memory at the
127+ current position of the file pointer; the file position is advanced by
128+ \code {1}.
127129\end {methoddesc }
128-
129-
0 commit comments