]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41843: Reenable use of sendfile in shutil module on Solaris (GH-23893)
authorJakub Kulík <Kulikjak@gmail.com>
Thu, 19 Sep 2024 14:47:05 +0000 (16:47 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Sep 2024 14:47:05 +0000 (14:47 +0000)
Doc/library/shutil.rst
Lib/shutil.py
Misc/NEWS.d/next/Library/2020-12-22-18-08-12.bpo-41843.q9Nh2r.rst [new file with mode: 0644]

index 220207e5f3cbbfdaf14a18b263ffa8be37a60a0f..e623c3df7beba6ab1b53266c66da08a7c5da059a 100644 (file)
@@ -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.14
+    Solaris now uses :func:`os.sendfile`.
+
 .. _shutil-copytree-example:
 
 copytree example
index 6037092a5e09f29657ecbc4e7844681866a029b9..89c12b76b61dfca2c670f6e5e030fa5cb28770dc 100644 (file)
@@ -48,7 +48,7 @@ COPY_BUFSIZE = 1024 * 1024 if _WINDOWS else 64 * 1024
 # 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, 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
+                    # Linux / Android / Solaris
                     elif _USE_CP_SENDFILE:
                         try:
                             _fastcopy_sendfile(fsrc, fdst)
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 (file)
index 0000000..4e525f7
--- /dev/null
@@ -0,0 +1,2 @@
+Solaris now uses :func:`os.sendfile` fast-copy syscall for more efficient
+:mod:`shutil` file copy related functions.