Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Jan 29, 2018

@vstinner
Copy link
Member Author

@pablogsal: would you mind to review my PR?

cc @YoSTEALTH @njsmith @csabella

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
Contributor

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'

Copy link
Member Author

Choose a reason for hiding this comment

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

done

(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
Copy link
Member

@pablogsal pablogsal Jan 29, 2018

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

?

Copy link
Member Author

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.
@vstinner
Copy link
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.

- :data:`RWF_HIPRI`
- :data:`RWF_NOWAIT`

Using non-zero flags requires Linux 4.6 or newer.
Copy link
Contributor

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

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

- :data:`RWF_DSYNC`
- :data:`RWF_SYNC`

Using non-zero flags requires Linux 4.7 or newer.
Copy link
Contributor

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

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
Contributor

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

Copy link
Member Author

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`.
Copy link
Member

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.
Copy link
Member

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`.
Copy link
Member

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*,
Copy link
Member

Choose a reason for hiding this comment

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

aan or the, or even better “at offset offset” would work I think.

@vstinner
Copy link
Member Author

vstinner commented Feb 1, 2018

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

@vstinner vstinner closed this Feb 1, 2018
@vstinner vstinner deleted the preadv_doc branch May 29, 2018 22:31
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