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

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, 11 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
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, offset_in, out, offset_out, count, flags=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*. *in* and *out* must reside in the same
Martin Panter 2016/04/29 03:33:44 It would be nice to start the sentence with a capi
680 filesystem, otherwise a *OSError* is raised with *errno* set to *errno.EXDEV* .
Martin Panter 2016/04/29 03:33:44 Usually, the markup for this is :exc:`OSError`, :a
681
682 This copy is done without using any user space buffers, and some
683 filesystems could implement optimizations. Because of this, errors
684 like UnicodeDecodingError will not arise on files opened in text mode
Martin Panter 2016/04/29 03:33:44 I don’t think text mode is relevant for file _desc
StyXman 2016/05/12 12:51:46 True, this is cruft from when I was trying to use
685 with the wrong encoding.
686
687 The flags argument is provided to allow for future extensions and
688 currently must be set to 0.
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 | « configure.ac ('k') | Modules/posixmodule.c » ('j') | Modules/posixmodule.c » ('J')

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