Browse Source
bpo-33671 / shutil.copyfile: use memoryview() with dynamic size on Windows (#7681)
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()pull/7799/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 153 additions and 64 deletions
-
6Doc/library/shutil.rst
-
28Doc/whatsnew/3.8.rst
-
72Lib/shutil.py
-
88Lib/test/test_shutil.py
-
15Misc/NEWS.d/next/Library/2018-05-28-23-25-17.bpo-33671.GIdKKi.rst
-
4Modules/clinic/posixmodule.c.h
-
4Modules/posixmodule.c
@ -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`.) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue