From e73501188681c30f23d01e45c584c210c230208b Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Tue, 22 Dec 2020 18:00:56 +0100 Subject: [PATCH 1/6] Reenable sendfile fast-copy syscall on Solaris --- Doc/library/shutil.rst | 5 ++++- Lib/shutil.py | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 220207e5f3cbbf..7e5d09ecc8b620 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -517,7 +517,7 @@ the use of userspace buffers in Python as in "``outfd.write(infd.read())``". On macOS `fcopyfile`_ is used to copy the file content (not metadata). -On Linux :func:`os.sendfile` is used. +On Linux and Solaris :func:`os.sendfile` is used. On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB instead of 64 KiB) and a :func:`memoryview`-based variant of @@ -529,6 +529,9 @@ file then shutil will silently fallback on using less efficient .. versionchanged:: 3.8 +.. versionchanged:: 3.10 + Solaris now uses :func:`os.sendfile` rather than no fast-copy operation. + .. _shutil-copytree-example: copytree example diff --git a/Lib/shutil.py b/Lib/shutil.py index 6037092a5e09f2..6403384837641b 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -48,7 +48,7 @@ # This should never be removed, see rationale in: # https://bugs.python.org/issue43743#msg393429 _USE_CP_SENDFILE = (hasattr(os, "sendfile") - and sys.platform.startswith(("linux", "android"))) + and sys.platform.startswith(("linux", "android", "solaris"))) _HAS_FCOPYFILE = posix and hasattr(posix, "_fcopyfile") # macOS # CMD defaults in Windows 10 @@ -110,7 +110,7 @@ def _fastcopy_fcopyfile(fsrc, fdst, flags): def _fastcopy_sendfile(fsrc, fdst): """Copy data from one regular mmap-like fd to another by using high-performance sendfile(2) syscall. - This should work on Linux >= 2.6.33 only. + This should work on Linux >= 2.6.33 and Solaris only. """ # Note: copyfileobj() is left alone in order to not introduce any # unexpected breakage. Possible risks by using zero-copy calls @@ -265,7 +265,7 @@ def copyfile(src, dst, *, follow_symlinks=True): return dst except _GiveupOnFastCopy: pass - # Linux + # Linux / Solaris elif _USE_CP_SENDFILE: try: _fastcopy_sendfile(fsrc, fdst) From 236d9effd4248f4df44a14fdf5eadf03ae15e61b Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Tue, 22 Dec 2020 18:09:32 +0100 Subject: [PATCH 2/6] Add NEWS entry --- .../next/Library/2020-12-22-18-08-12.bpo-41843.q9Nh2r.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2020-12-22-18-08-12.bpo-41843.q9Nh2r.rst diff --git a/Misc/NEWS.d/next/Library/2020-12-22-18-08-12.bpo-41843.q9Nh2r.rst b/Misc/NEWS.d/next/Library/2020-12-22-18-08-12.bpo-41843.q9Nh2r.rst new file mode 100644 index 00000000000000..4e525f7ed6a757 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-12-22-18-08-12.bpo-41843.q9Nh2r.rst @@ -0,0 +1,2 @@ +Solaris now uses :func:`os.sendfile` fast-copy syscall for more efficient +:mod:`shutil` file copy related functions. From 2713127d03252fb33958bcbd5bb85b9dbdf7c25a Mon Sep 17 00:00:00 2001 From: Jakub Kulik Date: Fri, 21 May 2021 17:35:15 +0200 Subject: [PATCH 3/6] Update version changed now that main is 3.11 --- Doc/library/shutil.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 7e5d09ecc8b620..f5e205662b46aa 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -529,7 +529,7 @@ file then shutil will silently fallback on using less efficient .. versionchanged:: 3.8 -.. versionchanged:: 3.10 +.. versionchanged:: 3.11 Solaris now uses :func:`os.sendfile` rather than no fast-copy operation. .. _shutil-copytree-example: From d80becff1a9ac8ed75da9f47c9e2f569c7042d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Mon, 20 Mar 2023 16:31:07 +0100 Subject: [PATCH 4/6] Update versionchanged once more to 3.12 --- Doc/library/shutil.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index f5e205662b46aa..3a2ddc9fbd0074 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -529,8 +529,8 @@ file then shutil will silently fallback on using less efficient .. versionchanged:: 3.8 -.. versionchanged:: 3.11 - Solaris now uses :func:`os.sendfile` rather than no fast-copy operation. +.. versionchanged:: 3.12.1 + Solaris now uses :func:`os.sendfile`. .. _shutil-copytree-example: From 944c17eef0bda32571313b1983f64b063f82c707 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Wed, 18 Sep 2024 15:23:39 +0200 Subject: [PATCH 5/6] minor changes --- Lib/shutil.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/shutil.py b/Lib/shutil.py index 6403384837641b..89c12b76b61dfc 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -110,7 +110,7 @@ def _fastcopy_fcopyfile(fsrc, fdst, flags): def _fastcopy_sendfile(fsrc, fdst): """Copy data from one regular mmap-like fd to another by using high-performance sendfile(2) syscall. - This should work on Linux >= 2.6.33 and Solaris only. + This should work on Linux >= 2.6.33, Android and Solaris. """ # Note: copyfileobj() is left alone in order to not introduce any # unexpected breakage. Possible risks by using zero-copy calls @@ -265,7 +265,7 @@ def copyfile(src, dst, *, follow_symlinks=True): return dst except _GiveupOnFastCopy: pass - # Linux / Solaris + # Linux / Android / Solaris elif _USE_CP_SENDFILE: try: _fastcopy_sendfile(fsrc, fdst) From a3d9e64123c5b623a6ba42c300cd9b0a9f3029f9 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 19 Sep 2024 16:20:45 +0200 Subject: [PATCH 6/6] Adjust version --- Doc/library/shutil.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 3a2ddc9fbd0074..e623c3df7beba6 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -529,7 +529,7 @@ file then shutil will silently fallback on using less efficient .. versionchanged:: 3.8 -.. versionchanged:: 3.12.1 +.. versionchanged:: 3.14 Solaris now uses :func:`os.sendfile`. .. _shutil-copytree-example: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy