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

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
« no previous file with comments | « configure.ac ('k') | Modules/posixmodule.c » ('j') | 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 672
673 Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive) , 673 Close all file descriptors from *fd_low* (inclusive) to *fd_high* (exclusive) ,
674 ignoring errors. Equivalent to (but much faster than):: 674 ignoring errors. Equivalent to (but much faster than)::
675 675
676 for fd in range(fd_low, fd_high): 676 for fd in range(fd_low, fd_high):
677 try: 677 try:
678 os.close(fd) 678 os.close(fd)
679 except OSError: 679 except OSError:
680 pass 680 pass
681 681
682
683 .. function:: copy_file_range(src, dst, count, offset_src=None, offset_dst=None, flags=0)
684
685 Copy *count* bytes from file descriptor *src*, starting from offset
686 *offset_src*, to file descriptor *dst*, starting from offset *offset_dst*.
687 If *offset_src* is None, then *src* is read from the current position;
688 respectively for *offset_dst*. The files pointed by *src* and *dst*
689 must reside in the same filesystem, otherwise a :exc:`OSError` is
690 raised with :attr:`~OSError.errno` set to :data:`errno.EXDEV`.
691
692 This copy is done without using any user space buffers, and some
693 filesystems could implement optimizations. The copy is done as if
694 both files are opened as binary.
695
696 The *flags* argument is provided for compatibility with the only currently
697 supported implementation (Linux >=4.5) to allow for future extensions, and
698 currently can only be 0.
699
700 The return value is the amount of bytes copied. This could be less than the
701 amount requested.
702
703 Availability: some recent flavors of Unix (see the man page
704 :manpage:`copy_file_range(2)` for further information).
705
706 .. versionadded:: 3.6
682 707
683 .. function:: device_encoding(fd) 708 .. function:: device_encoding(fd)
684 709
685 Return a string describing the encoding of the device associated with *fd* 710 Return a string describing the encoding of the device associated with *fd*
686 if it is connected to a terminal; else return :const:`None`. 711 if it is connected to a terminal; else return :const:`None`.
687 712
688 713
689 .. function:: dup(fd) 714 .. function:: dup(fd)
690 715
691 Return a duplicate of file descriptor *fd*. The new file descriptor is 716 Return a duplicate of file descriptor *fd*. The new file descriptor is
(...skipping 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after
3781 3806
3782 .. versionchanged:: 3.5.2 3807 .. versionchanged:: 3.5.2
3783 On Linux, if ``getrandom()`` blocks (the urandom entropy pool is not 3808 On Linux, if ``getrandom()`` blocks (the urandom entropy pool is not
3784 initialized yet), fall back on reading ``/dev/urandom``. 3809 initialized yet), fall back on reading ``/dev/urandom``.
3785 3810
3786 .. versionchanged:: 3.5 3811 .. versionchanged:: 3.5
3787 On Linux 3.17 and newer, the ``getrandom()`` syscall is now used 3812 On Linux 3.17 and newer, the ``getrandom()`` syscall is now used
3788 when available. On OpenBSD 5.6 and newer, the C ``getentropy()`` 3813 when available. On OpenBSD 5.6 and newer, the C ``getentropy()``
3789 function is now used. These functions avoid the usage of an internal file 3814 function is now used. These functions avoid the usage of an internal file
3790 descriptor. 3815 descriptor.
OLDNEW
« no previous file with comments | « configure.ac ('k') | Modules/posixmodule.c » ('j') | no next file with comments »

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