-
-
Notifications
You must be signed in to change notification settings - Fork 34k
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
Conversation
|
@pablogsal: would you mind to review my PR? |
Doc/library/os.rst
Outdated
| 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. |
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
Doc/library/os.rst
Outdated
| (sysconf() value SC_IOV_MAX) on the number of buffers that can be used. | ||
| processed in array order. Entire contents of the first buffer is written | ||
| before proceeding to the second, and so on. The operating system may set a | ||
| limit (sysconf() value SC_IOV_MAX) on the number of buffers that can be |
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.
It will make sense to change
sysconf() -> :func:`sysconf`
and
SC_IOV_MAX -> ``'SC_IOV_MAX'``
?
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.
Oh wait, I didn't want to modify this documentation... But then I read the doc, and oh, all these documentations can be enhanced...
pread(): rename second parameter from 'buffersize' to 'n', reuse read() parameter name. The parameter is positional-only and so this change is backward compatible.
|
Sorry for reviewers, but I basically rewrote my whole PR to cleanup the documentation of all read and write functions:
The documentation should now be more consistent. |
Doc/library/os.rst
Outdated
| - :data:`RWF_HIPRI` | ||
| - :data:`RWF_NOWAIT` | ||
|
|
||
| Using non-zero flags requires Linux 4.6 or newer. |
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.
could be change this to: "Using non-zero flags requires preadv2 support on Linux 4.7 or newer."
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.
I'm trying to avoid mentioning preadv2(). Do you think that you must mention it?
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.
All the flags actually belong to preadv2() function though, maybe a tiny mention wont hurt?
Its your call.
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.
You should absolutely mention preadv2 and pwritev2. At the point someone is using these features in the os module they're also reading man pages and lwn articles, and you want to help them make the connection. If someone wonders whether python has a wrapper for preadv2 then searching for that in the docs should find os.preadv.
Doc/library/os.rst
Outdated
| - :data:`RWF_DSYNC` | ||
| - :data:`RWF_SYNC` | ||
|
|
||
| Using non-zero flags requires Linux 4.7 or newer. |
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.
could be also change this to: "Using non-zero flags requires pwritev2 support on Linux 4.7 or newer."
Doc/library/os.rst
Outdated
| 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, |
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.
should be "Availability: Linux 2.6.30, FreeBSD 6.0 and newer."
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.
"and newer" is commonly used in os.rst documentation (i fixed the typo)
| The operating system may set a limit (:func:`sysconf` value | ||
| ``'SC_IOV_MAX'``) on the number of buffers that can be used. | ||
|
|
||
| Combine the functionality of :func:`os.readv` and :func:`os.pread`. |
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.
This reads as an instruction, but it is no longer clear it is for the implementation. Maybe drop the imperative and write “This function combines the functionality . . .”. Also applies to pwritev below.
| - :data:`RWF_NOWAIT` | ||
|
|
||
| Return the total number of bytes actually read which can be less than the | ||
| total capacity of all the objects. |
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.
Needs a comma: “. . . number of bytes read, which can be less . . .”. Applies to readv below too.
|
|
||
| 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`. |
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.
I’m confused. Normally you access errno as an attribute of an exception. Do the Python wrapper(s) return −1 or raise OSError/BlockingIOError?
| (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 a offset *offset*, |
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.
a → an or the, or even better “at offset offset” would work I think.
|
I abandon my change. Feel free to reuse my change to create a new PR if you want to enhance the documentation. |
https://bugs.python.org/issue31368