diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2018-06-19 15:27:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-19 15:27:29 (GMT) |
commit | c7f02a965936f197354d7f4e6360f4cfc86817ed (patch) | |
tree | 9402cdb5daa1881eefce00dbc70c8b2dfc7f40f7 /Misc | |
parent | 936f03e7fafc28fd6fdfba11d162c776b89c0167 (diff) | |
download | cpython-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 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-05-28-23-25-17.bpo-33671.GIdKKi.rst | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Misc/NEWS.d/next/Library/2018-05-28-23-25-17.bpo-33671.GIdKKi.rst b/Misc/NEWS.d/next/Library/2018-05-28-23-25-17.bpo-33671.GIdKKi.rst index 5fd7e1f..b1523f2 100644 --- a/Misc/NEWS.d/next/Library/2018-05-28-23-25-17.bpo-33671.GIdKKi.rst +++ b/Misc/NEWS.d/next/Library/2018-05-28-23-25-17.bpo-33671.GIdKKi.rst @@ -1,11 +1,10 @@ :func:`shutil.copyfile`, :func:`shutil.copy`, :func:`shutil.copy2`, :func:`shutil.copytree` and :func:`shutil.move` use platform-specific -fast-copy syscalls on Linux, Solaris and OSX in order to copy the file -more efficiently. 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 is about +26% on Linux, -+50% on OSX and +38% on Windows. Also, much less CPU cycles are consumed +fast-copy syscalls on Linux, Solaris and macOS in order to copy the file +more efficiently. +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 512MiB file is about +26% on Linux, +50% on macOS and ++40% on Windows. Also, much less CPU cycles are consumed. (Contributed by Giampaolo Rodola' in :issue:`25427`.) |