summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-06-19 15:27:29 (GMT)
committerGitHub <noreply@github.com>2018-06-19 15:27:29 (GMT)
commitc7f02a965936f197354d7f4e6360f4cfc86817ed (patch)
tree9402cdb5daa1881eefce00dbc70c8b2dfc7f40f7 /Doc
parent936f03e7fafc28fd6fdfba11d162c776b89c0167 (diff)
downloadcpython-c7f02a965936f197354d7f4e6360f4cfc86817ed.zip
cpython-c7f02a965936f197354d7f4e6360f4cfc86817ed.tar.gz
cpython-c7f02a965936f197354d7f4e6360f4cfc86817ed.tar.bz2
bpo-33671 / shutil.copyfile: use memoryview() with dynamic size on Windows (#7681)
bpo-33671 * use memoryview() with size == file size on Windows, see https://github.com/python/cpython/pull/7160#discussion_r195405230 * release intermediate (sliced) memoryview immediately * replace "OSX" occurrences with "macOS" * add some unittests for copyfileobj()
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/shutil.rst6
-rw-r--r--Doc/whatsnew/3.8.rst28
2 files changed, 22 insertions, 12 deletions
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index a3b87ee..c692cf4 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -407,11 +407,15 @@ efficiently (see :issue:`33671`).
"fast-copy" means that the copying operation occurs within the kernel, avoiding
the use of userspace buffers in Python as in "``outfd.write(infd.read())``".
-On OSX `fcopyfile`_ is used to copy the file content (not metadata).
+On macOS `fcopyfile`_ is used to copy the file content (not metadata).
On Linux, Solaris and other POSIX platforms where :func:`os.sendfile` supports
copies between 2 regular file descriptors :func:`os.sendfile` is used.
+On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
+instead of 16 KiB) and a :func:`memoryview`-based variant of
+:func:`shutil.copyfileobj` is used.
+
If the fast-copy operation fails and no data was written in the destination
file then shutil will silently fallback on using less efficient
:func:`copyfileobj` function internally.
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 58be90f..32c45ec 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -95,20 +95,18 @@ Optimizations
* :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`,
:func:`shutil.copytree` and :func:`shutil.move` use platform-specific
- "fast-copy" syscalls on Linux, OSX and Solaris in order to copy the file more
- efficiently.
+ "fast-copy" syscalls on Linux, macOS and Solaris in order to copy the file
+ more efficiently.
"fast-copy" means that the copying operation occurs within the kernel,
avoiding the use of userspace buffers in Python as in
"``outfd.write(infd.read())``".
- All other platforms not using such technique will rely on a faster
- :func:`shutil.copyfile` implementation using :func:`memoryview`,
- :class:`bytearray` and
- :meth:`BufferedIOBase.readinto() <io.BufferedIOBase.readinto>`.
- Finally, :func:`shutil.copyfile` default buffer size on Windows was increased
- from 16KB to 1MB.
- The speedup for copying a 512MB file within the same partition is about +26%
- on Linux, +50% on OSX and +38% on Windows. Also, much less CPU cycles are
- consumed.
+ On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
+ instead of 16 KiB) and a :func:`memoryview`-based variant of
+ :func:`shutil.copyfileobj` is used.
+ The speedup for copying a 512 MiB file within the same partition is about
+ +26% on Linux, +50% on macOS and +40% on Windows. Also, much less CPU cycles
+ are consumed.
+ See :ref:`shutil-platform-dependent-efficient-copy-operations` section.
(Contributed by Giampaolo Rodola' in :issue:`25427`.)
* The default protocol in the :mod:`pickle` module is now Protocol 4,
@@ -179,6 +177,14 @@ Changes in the Python API
* The :class:`cProfile.Profile` class can now be used as a context
manager. (Contributed by Scott Sanderson in :issue:`29235`.)
+* :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`,
+ :func:`shutil.copytree` and :func:`shutil.move` use platform-specific
+ "fast-copy" syscalls (see
+ :ref:`shutil-platform-dependent-efficient-copy-operations` section).
+
+* :func:`shutil.copyfile` default buffer size on Windows was changed from
+ 16 KiB to 1 MiB.
+
CPython bytecode changes
------------------------