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

Side by Side Diff: Doc/library/os.rst

Issue 26826: Expose new copy_file_range() syscal in os module and use it to improve shutils.copy()
Patch Set: Created 3 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`os` --- Miscellaneous operating system interfaces 1 :mod:`os` --- Miscellaneous operating system interfaces
2 ======================================================= 2 =======================================================
3 3
4 .. module:: os 4 .. module:: os
5 :synopsis: Miscellaneous operating system interfaces. 5 :synopsis: Miscellaneous operating system interfaces.
6 6
7 7
8 This module provides a portable way of using operating system dependent 8 This module provides a portable way of using operating system dependent
9 functionality. If you just want to read or write a file see :func:`open`, if 9 functionality. If you just want to read or write a file see :func:`open`, if
10 you want to manipulate paths, see the :mod:`os.path` module, and if you want to 10 you want to manipulate paths, see the :mod:`os.path` module, and if you want to
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 663
664 Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive) , 664 Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive) ,
665 ignoring errors. Equivalent to (but much faster than):: 665 ignoring errors. Equivalent to (but much faster than)::
666 666
667 for fd in range(fd_low, fd_high): 667 for fd in range(fd_low, fd_high):
668 try: 668 try:
669 os.close(fd) 669 os.close(fd)
670 except OSError: 670 except OSError:
671 pass 671 pass
672 672
673
674 .. function:: copy_file_range(in, out, count, offset_in=None, offset_out=None, f lags=0)
675
676 Copy *count* bytes from file descriptor *in*, starting from offset
677 *offset_in*, to file descriptor *out*, starting from offset *offset_out*.
678 If *offset_in* is None, then *in* is read from the current position;
679 respectively for *offset_out*. The files pointed by *in* and *out*
680 must reside in the same filesystem, otherwise a :exc:`OSError` is
681 raised with :attr:`~OSError.errno` set to :data:`errno.EXDEV`.
682
683 This copy is done without using any user space buffers, and some
684 filesystems could implement optimizations. The copy is done as if
685 both files are opened as binay, so no transcoding is possible.
Martin Panter 2016/05/08 12:23:22 You dropped the R in bina[r]y
686
687 The flags argument is provided to allow for future extensions and
Martin Panter 2016/05/08 12:42:24 *flags*
688 currently must be set to 0.
Martin Panter 2016/05/08 12:42:24 Might be more correct to say something like “For t
StyXman 2016/05/12 12:51:46 Given that it would be a keyword argument and that
689
690 Availability: some recent flavors of Unix (see the man page
691 :manpage:`copy_file_range(2)` for further information).
692
693 .. versionadded:: 3.6
673 694
674 .. function:: device_encoding(fd) 695 .. function:: device_encoding(fd)
675 696
676 Return a string describing the encoding of the device associated with *fd* 697 Return a string describing the encoding of the device associated with *fd*
677 if it is connected to a terminal; else return :const:`None`. 698 if it is connected to a terminal; else return :const:`None`.
678 699
679 700
680 .. function:: dup(fd) 701 .. function:: dup(fd)
681 702
682 Return a duplicate of file descriptor *fd*. The new file descriptor is 703 Return a duplicate of file descriptor *fd*. The new file descriptor is
(...skipping 3082 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 :exc:`NotImplementedError` will be raised. 3786 :exc:`NotImplementedError` will be raised.
3766 3787
3767 For an easy-to-use interface to the random number generator 3788 For an easy-to-use interface to the random number generator
3768 provided by your platform, please see :class:`random.SystemRandom`. 3789 provided by your platform, please see :class:`random.SystemRandom`.
3769 3790
3770 .. versionchanged:: 3.5 3791 .. versionchanged:: 3.5
3771 On Linux 3.17 and newer, the ``getrandom()`` syscall is now used 3792 On Linux 3.17 and newer, the ``getrandom()`` syscall is now used
3772 when available. On OpenBSD 5.6 and newer, the C ``getentropy()`` 3793 when available. On OpenBSD 5.6 and newer, the C ``getentropy()``
3773 function is now used. These functions avoid the usage of an internal file 3794 function is now used. These functions avoid the usage of an internal file
3774 descriptor. 3795 descriptor.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

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