Repository navigation
bpo-31368: Enhance os.preadv() documentation #5415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
52b4da1
bpo-31368: Enhance os.preadv() documentation
vstinner 5809a57
What's New: describe added functions
vstinner 14eafd2
Adding missing "the" in the doc
vstinner 622a8ec
Move preadv to fix ordering
vstinner 40457cb
Cleanup other read/write docs
vstinner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1104,39 +1104,48 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo | |
|
|
||
| .. function:: pwritev(fd, buffers, offset, flags=0) | ||
|
|
||
| Combines the functionality of :func:`os.writev` and :func:`os.pwrite`. It | ||
| writes the contents of *buffers* to file descriptor *fd* at offset *offset*. | ||
| *buffers* must be a sequence of :term:`bytes-like objects <bytes-like object>`. | ||
| Buffers are processed in array order. Entire contents of first buffer is written | ||
| before proceeding to second, and so on. The operating system may set a limit | ||
| (sysconf() value SC_IOV_MAX) on the number of buffers that can be used. | ||
| :func:`~os.pwritev` writes the contents of each object to the file descriptor | ||
| and returns the total number of bytes written. | ||
| Write the *buffers* contents to file descriptor *fd* at offset *offset*. | ||
| *buffers* must be a sequence of :term:`bytes-like objects <bytes-like | ||
| object>`. Buffers are processed in array order. Entire contents of first | ||
| buffer is written before proceeding to second, and so on. | ||
|
|
||
| Return the total number of bytes written. | ||
|
|
||
| Combine the functionality of :func:`os.writev` and :func:`os.pwrite`. | ||
|
|
||
| The *flags* argument contains a bitwise OR of zero or more of the following | ||
| flags: | ||
|
|
||
| - RWF_DSYNC | ||
| - RWF_SYNC | ||
| - :data:`RWF_DSYNC` | ||
| - :data:`RWF_SYNC` | ||
|
|
||
| Using non-zero flags requires Linux 4.7 or newer. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be also change this to: "Using non-zero flags requires pwritev2 support on Linux 4.7 or newer." |
||
|
|
||
| Availability: Linux (version 2.6.30), FreeBSD 6.0 and newer, | ||
| OpenBSD (version 2.7 and newer). | ||
| The operating system may set a limit (:func:`sysconf` value | ||
| ``'SC_IOV_MAX'``) on the number of buffers that can be used. | ||
|
|
||
| Availability: Linux 2.6.30 and newer, FreeBSD 6.0 and newer, | ||
| OpenBSD 2.7 and newer. | ||
|
|
||
| .. versionadded:: 3.7 | ||
|
|
||
| .. data:: RWF_DSYNC (since Linux 4.7) | ||
| Provide a per-write equivalent of the O_DSYNC open(2) flag. This flag | ||
| is meaningful only for pwritev2(), and its effect applies only to the | ||
| data range written by the system call. | ||
|
|
||
| .. data:: RWF_DSYNC | ||
|
|
||
| Provide a per-write equivalent of the :data:`O_DSYNC` ``open(2)`` flag. This | ||
| flag effect applies only to the data range written by the system call. | ||
|
|
||
| Availability: Linux 4.7 and newer. | ||
|
|
||
| .. versionadded:: 3.7 | ||
|
|
||
| .. data:: RWF_SYNC (since Linux 4.7) | ||
| Provide a per-write equivalent of the O_SYNC open(2) flag. This flag is | ||
| meaningful only for pwritev2(), and its effect applies only to the data | ||
| range written by the system call. | ||
|
|
||
| .. data:: RWF_SYNC | ||
|
|
||
| Provide a per-write equivalent of the :data:`O_SYNC` ``open(2)`` flag. This | ||
| flag effect applies only to the data range written by the system call. | ||
|
|
||
| Availability: Linux 4.7 and newer. | ||
|
|
||
| .. versionadded:: 3.7 | ||
|
|
||
|
|
@@ -1237,45 +1246,58 @@ or `the MSDN <https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Windo | |
|
|
||
| .. function:: preadv(fd, buffers, offset, flags=0) | ||
|
|
||
| Combines the functionality of :func:`os.readv` and :func:`os.pread`. It | ||
| reads from a file descriptor *fd* into a number of mutable :term:`bytes-like | ||
| objects <bytes-like object>` *buffers*. As :func:`os.readv`, it will transfer | ||
| data into each buffer until it is full and then move on to the next buffer in | ||
| the sequence to hold the rest of the data. Its fourth argument, *offset*, | ||
| specifies the file offset at which the input operation is to be performed. | ||
| :func:`~os.preadv` return the total number of bytes read (which can be less than | ||
| the total capacity of all the objects). | ||
| Read from a file descriptor *fd* from offset *offset* into mutable | ||
| :term:`bytes-like objects <bytes-like object>` *buffers*. Transfer data into | ||
| each buffer until it is full and then move on to the next buffer in the | ||
| sequence to hold the rest of the data. | ||
|
|
||
| Return the total number of bytes read which can be less than the total | ||
| capacity of all the objects. | ||
|
|
||
| Combine the functionality of :func:`os.readv` and :func:`os.pread`. | ||
|
|
||
| The flags argument contains a bitwise OR of zero or more of the following | ||
| flags: | ||
|
|
||
| - RWF_HIPRI | ||
| - RWF_NOWAIT | ||
| - :data:`RWF_HIPRI` | ||
| - :data:`RWF_NOWAIT` | ||
|
|
||
| Using non-zero flags requires Linux 4.6 or newer. | ||
|
|
||
| Availability: Linux (version 2.6.30), FreeBSD 6.0 and newer, | ||
| OpenBSD (version 2.7 and newer). | ||
| The operating system may set a limit (:func:`sysconf` value | ||
| ``'SC_IOV_MAX'``) on the number of buffers that can be used. | ||
|
|
||
| Availability: Linux 2.6.30 abd newer, FreeBSD 6.0 and newer, | ||
| OpenBSD 2.7 and newer. | ||
|
|
||
| .. versionadded:: 3.7 | ||
|
|
||
|
|
||
| .. data:: RWF_HIPRI (since Linux 4.6) | ||
| High priority read/write. Allows block-based filesystems to use polling | ||
| of the device, which provides lower latency, but may use additional | ||
| resources. (Currently, this feature is usable only on a file descriptor | ||
| opened using the O_DIRECT flag.) | ||
| .. data:: RWF_NOWAIT | ||
|
|
||
| Do not wait for data which is not immediately available. If this flag is | ||
| specified, the system call will return instantly if it would have to read | ||
| data from the backing storage or wait for a lock. | ||
|
|
||
| If some data was successfully read, it will return the number of bytes read. | ||
| If no bytes were read, it will return ``-1`` and set errno to | ||
| :data:`errno.EAGAIN`. | ||
|
|
||
| Availability: Linux 4.14 and newer. | ||
|
|
||
| .. versionadded:: 3.7 | ||
|
|
||
|
|
||
| .. data:: RWF_NOWAIT (since Linux 4.14) | ||
| Do not wait for data which is not immediately available. If this flag | ||
| is specified, the preadv2() system call will return instantly | ||
| if it would have to read data from the backing storage or wait for a lock. | ||
| If some data was successfully read, it will return the number of bytes | ||
| read. If no bytes were read, it will return -1 and set errno to EAGAIN. | ||
| Currently, this flag is meaningful only for preadv2(). | ||
| .. data:: RWF_HIPRI | ||
|
|
||
| High priority read/write. Allows block-based filesystems to use polling | ||
| of the device, which provides lower latency, but may use additional | ||
| resources. | ||
|
|
||
| Currently, on Linux, this feature is usable only on a file descriptor opened | ||
| using the O_DIRECT flag. | ||
|
|
||
| Availability: Linux 4.6 and newer. | ||
|
|
||
| .. versionadded:: 3.7 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Entire contents of the first buffer'
'before proceeding to the second'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done