Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(206566)

Delta Between Two Patch Sets: Doc/library/mmap.rst

Issue 23001: Accept mutable bytes-like objects
Left Patch Set: Created 5 years ago
Right Patch Set: Created 4 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
LEFTRIGHT
(no file at all)
1 :mod:`mmap` --- Memory-mapped file support 1 :mod:`mmap` --- Memory-mapped file support
2 ========================================== 2 ==========================================
3 3
4 .. module:: mmap 4 .. module:: mmap
5 :synopsis: Interface to memory-mapped files for Unix and Windows. 5 :synopsis: Interface to memory-mapped files for Unix and Windows.
6 6
7 7
8 Memory-mapped file objects behave like both :class:`bytearray` and like 8 Memory-mapped file objects behave like both :class:`bytearray` and like
9 :term:`file objects <file object>`. You can use mmap objects in most places 9 :term:`file objects <file object>`. You can use mmap objects in most places
10 where :class:`bytearray` are expected; for example, you can use the :mod:`re` 10 where :class:`bytearray` are expected; for example, you can use the :mod:`re`
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 .. versionadded:: 3.2 167 .. versionadded:: 3.2
168 168
169 169
170 .. method:: find(sub[, start[, end]]) 170 .. method:: find(sub[, start[, end]])
171 171
172 Returns the lowest index in the object where the subsequence *sub* is 172 Returns the lowest index in the object where the subsequence *sub* is
173 found, such that *sub* is contained in the range [*start*, *end*]. 173 found, such that *sub* is contained in the range [*start*, *end*].
174 Optional arguments *start* and *end* are interpreted as in slice notation. 174 Optional arguments *start* and *end* are interpreted as in slice notation.
175 Returns ``-1`` on failure. 175 Returns ``-1`` on failure.
176 176
177 .. versionchanged: 3.5
178 Writable :term:`bytes-like object` is now accepted.
179
177 180
178 .. method:: flush([offset[, size]]) 181 .. method:: flush([offset[, size]])
179 182
180 Flushes changes made to the in-memory copy of a file back to disk. Without 183 Flushes changes made to the in-memory copy of a file back to disk. Without
181 use of this call there is no guarantee that changes are written back befor e 184 use of this call there is no guarantee that changes are written back befor e
182 the object is destroyed. If *offset* and *size* are specified, only 185 the object is destroyed. If *offset* and *size* are specified, only
183 changes to the given range of bytes will be flushed to disk; otherwise, th e 186 changes to the given range of bytes will be flushed to disk; otherwise, th e
184 whole extent of the mapping is flushed. 187 whole extent of the mapping is flushed.
185 188
186 **(Windows version)** A nonzero value returned indicates success; zero 189 **(Windows version)** A nonzero value returned indicates success; zero
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 raise a :exc:`TypeError` exception. 230 raise a :exc:`TypeError` exception.
228 231
229 232
230 .. method:: rfind(sub[, start[, end]]) 233 .. method:: rfind(sub[, start[, end]])
231 234
232 Returns the highest index in the object where the subsequence *sub* is 235 Returns the highest index in the object where the subsequence *sub* is
233 found, such that *sub* is contained in the range [*start*, *end*]. 236 found, such that *sub* is contained in the range [*start*, *end*].
234 Optional arguments *start* and *end* are interpreted as in slice notation. 237 Optional arguments *start* and *end* are interpreted as in slice notation.
235 Returns ``-1`` on failure. 238 Returns ``-1`` on failure.
236 239
240 .. versionchanged: 3.5
241 Writable :term:`bytes-like object` is now accepted.
242
237 243
238 .. method:: seek(pos[, whence]) 244 .. method:: seek(pos[, whence])
239 245
240 Set the file's current position. *whence* argument is optional and 246 Set the file's current position. *whence* argument is optional and
241 defaults to ``os.SEEK_SET`` or ``0`` (absolute file positioning); other 247 defaults to ``os.SEEK_SET`` or ``0`` (absolute file positioning); other
242 values are ``os.SEEK_CUR`` or ``1`` (seek relative to the current 248 values are ``os.SEEK_CUR`` or ``1`` (seek relative to the current
243 position) and ``os.SEEK_END`` or ``2`` (seek relative to the file's end). 249 position) and ``os.SEEK_END`` or ``2`` (seek relative to the file's end).
244 250
245 251
246 .. method:: size() 252 .. method:: size()
247 253
248 Return the length of the file, which can be larger than the size of the 254 Return the length of the file, which can be larger than the size of the
249 memory-mapped area. 255 memory-mapped area.
250 256
251 257
252 .. method:: tell() 258 .. method:: tell()
253 259
254 Returns the current position of the file pointer. 260 Returns the current position of the file pointer.
255 261
256 262
257 .. method:: write(bytes) 263 .. method:: write(bytes)
258 264
259 Write the bytes in *bytes* into memory at the current position of the 265 Write the bytes in *bytes* into memory at the current position of the
260 file pointer; the file position is updated to point after the bytes that 266 file pointer; the file position is updated to point after the bytes that
261 were written. If the mmap was created with :const:`ACCESS_READ`, then 267 were written. If the mmap was created with :const:`ACCESS_READ`, then
262 writing to it will raise a :exc:`TypeError` exception. 268 writing to it will raise a :exc:`TypeError` exception.
263 269
270 .. versionchanged: 3.5
271 Writable :term:`bytes-like object` is now accepted.
272
264 273
265 .. method:: write_byte(byte) 274 .. method:: write_byte(byte)
266 275
267 Write the integer *byte* into memory at the current 276 Write the integer *byte* into memory at the current
268 position of the file pointer; the file position is advanced by ``1``. If 277 position of the file pointer; the file position is advanced by ``1``. If
269 the mmap was created with :const:`ACCESS_READ`, then writing to it will 278 the mmap was created with :const:`ACCESS_READ`, then writing to it will
270 raise a :exc:`TypeError` exception. 279 raise a :exc:`TypeError` exception.
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+