]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117641: Improve the perfornance of posixpath.commonpath() (#117652)
authorNice Zombies <nineteendo19d0@gmail.com>
Thu, 18 Apr 2024 07:26:34 +0000 (09:26 +0200)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2024 07:26:34 +0000 (09:26 +0200)
Lib/posixpath.py
Misc/NEWS.d/next/Core and Builtins/2024-04-08-19-30-38.gh-issue-117641.oaBGSJ.rst [new file with mode: 0644]

index 79cda50753e0d201dcb8ac44fd88d487db093c53..f1960ddb88e59055d8bf257a5ac6042f64acc8d1 100644 (file)
@@ -550,7 +550,7 @@ def commonpath(paths):
         split_paths = [path.split(sep) for path in paths]
 
         try:
-            isabs, = set(p[:1] == sep for p in paths)
+            isabs, = {p.startswith(sep) for p in paths}
         except ValueError:
             raise ValueError("Can't mix absolute and relative paths") from None
 
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-04-08-19-30-38.gh-issue-117641.oaBGSJ.rst b/Misc/NEWS.d/next/Core and Builtins/2024-04-08-19-30-38.gh-issue-117641.oaBGSJ.rst
new file mode 100644 (file)
index 0000000..e313c13
--- /dev/null
@@ -0,0 +1 @@
+Speedup :func:`os.path.commonpath` on Unix.