diff --git a/Lib/ntpath.py b/Lib/ntpath.py index f9f6c78566e8ed..da5231ff2c0931 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -111,7 +111,7 @@ def join(path, *paths): if not paths: path[:0] + sep #23780: Ensure compatible data type even if p is null. result_drive, result_root, result_path = splitroot(path) - for p in map(os.fspath, paths): + for p in paths: p_drive, p_root, p_path = splitroot(p) if p_root: # Second path is absolute diff --git a/Lib/posixpath.py b/Lib/posixpath.py index b7fbdff20cac99..79e65587e66282 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -79,7 +79,8 @@ def join(a, *p): try: if not p: path[:0] + sep #23780: Ensure compatible data type even if p is null. - for b in map(os.fspath, p): + for b in p: + b = os.fspath(b) if b.startswith(sep): path = b elif not path or path.endswith(sep): diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-04-08-20-26-15.gh-issue-117648.NzVEa7.rst b/Misc/NEWS.d/next/Core and Builtins/2024-04-08-20-26-15.gh-issue-117648.NzVEa7.rst new file mode 100644 index 00000000000000..c7e0dfcc461fc9 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-04-08-20-26-15.gh-issue-117648.NzVEa7.rst @@ -0,0 +1 @@ +Speedup :func:`os.path.join` by up to 6% on Windows.