FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-31368: Enhance os.preadv() documentation by vstinner · Pull Request #5415 · python/cpython · GitHub

Repository navigation

bpo-31368: Enhance os.preadv() documentation - #5415

Closed
vstinner wants to merge 5 commits into
python:masterfrom
vstinner:preadv_doc
Closed

vstinner wants to merge 5 commits into
python:masterfrom
vstinner:preadv_doc

Conversation

vstinner commented Jan 29, 2018 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

@pablogsal: would you mind to review my PR?

cc @YoSTEALTH @njsmith @csabella

Comment thread 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

'Entire contents of the first buffer'
'before proceeding to the second'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

done

Comment thread 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

pablogsal Jan 29, 2018 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It will make sense to change

 sysconf() -> :func:`sysconf` 

and

SC_IOV_MAX ->  ``'SC_IOV_MAX'``

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Copy link
Copy Markdown
Member Author

Sorry for reviewers, but I basically rewrote my whole PR to cleanup the documentation of all read and write functions:

  • read, pread, readv, preadv
  • write, pwrite, writev, pwritev

The documentation should now be more consistent.

Comment thread Doc/library/os.rst Outdated
- :data:`RWF_HIPRI`
- :data:`RWF_NOWAIT`

Using non-zero flags requires Linux 4.6 or newer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

could be change this to: "Using non-zero flags requires preadv2 support on Linux 4.7 or newer."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm trying to avoid mentioning preadv2(). Do you think that you must mention it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

All the flags actually belong to preadv2() function though, maybe a tiny mention wont hurt?
Its your call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread Doc/library/os.rst Outdated
- :data:`RWF_DSYNC`
- :data:`RWF_SYNC`

Using non-zero flags requires Linux 4.7 or newer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

could be also change this to: "Using non-zero flags requires pwritev2 support on Linux 4.7 or newer."

Comment thread 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

should be "Availability: Linux 2.6.30, FreeBSD 6.0 and newer."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

"and newer" is commonly used in os.rst documentation (i fixed the typo)

Comment thread Doc/library/os.rst
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`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

Comment thread Doc/library/os.rst
- :data:`RWF_NOWAIT`

Return the total number of bytes actually read which can be less than the
total capacity of all the objects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Needs a comma: “. . . number of bytes read, which can be less . . .”. Applies to readv below too.

Comment thread Doc/library/os.rst

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`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I’m confused. Normally you access errno as an attribute of an exception. Do the Python wrapper(s) return −1 or raise OSError/BlockingIOError?

Comment thread Doc/library/os.rst
(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*,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

a → an or the, or even better “at offset offset” would work I think.

vstinner commented Feb 1, 2018

Copy link
Copy Markdown
Member Author

I abandon my change. Feel free to reuse my change to create a new PR if you want to enhance the documentation.

vstinner closed this Feb 1, 2018
vstinner deleted the preadv_doc branch May 29, 2018 22:31
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL