gh-117648: Improve performance of os.join (#117654)
Replace map() with a method call in the loop body. Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
This commit is contained in:
parent
19a2202067
commit
99852d9e65
@ -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
|
||||
|
@ -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):
|
||||
|
@ -0,0 +1 @@
|
||||
Speedup :func:`os.path.join` by up to 6% on Windows.
|
Loading…
x
Reference in New Issue
Block a user