You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use set comprehension for posixpath.commonpath() #117641
We can use a set comprehension to check if no absolute and relative paths are mixed:
-try:- isabs, = set(p[:1] == sep for p in paths)-except ValueError:- raise ValueError("Can't mix absolute and relative paths") from None+if len({p.startswith(sep) for p in paths}) != 1:+ raise ValueError("Can't mix absolute and relative paths")
-prefix = sep if isabs else sep[:0]+prefix = sep if paths[0].startswith(sep) else sep[:0]
This is faster and more readable.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Activity
gh-117641: Improve the perfornance of posixpath.commonpath() (#117652)