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
Optimize joining of pathlib.PurePath() arguments. #104996
In Python 3.12, when multiple arguments are given to PurePath(), the initialiser calls os.path.join() to join them. This is reasonably slow. For Python 3.13 we can make it faster by:
Deferring joining of arguments until strictly needed
The reason for (maybe) re-implementing os.path.join():
Any implementation of path joining must keep a running record of the current drive, root and tail, and update them by calling splitroot() on each argument. The final drive, root and tail would be useful in pathlib to implement drive, root and _tail, but os.path.join() only makes available the joined path, which is a combination of the drive, root and tail. As a consequence, we need to call splitroot() all over again in _parse_path().
Activity
pythonGH-104996: Defer joining of `pathlib.PurePath()` arguments.
barneygale commentedon May 26, 2023
The reason for (maybe) re-implementing
os.path.join():Any implementation of path joining must keep a running record of the current drive, root and tail, and update them by calling
splitroot()on each argument. The final drive, root and tail would be useful in pathlib to implementdrive,rootand_tail, butos.path.join()only makes available the joined path, which is a combination of the drive, root and tail. As a consequence, we need to callsplitroot()all over again in_parse_path().Merge branch 'main' into pythongh-104996-pathlib-defer-path-joining
GH-104996: Defer joining of `pathlib.PurePath()` arguments. (GH-104999)
pythonGH-104996: Defer joining of `pathlib.PurePath()` arguments. (py…
[3.12] pythonGH-104996: Defer joining of `pathlib.PurePath()` argumen…
[3.12] GH-104996: Defer joining of `pathlib.PurePath()` arguments. (G…
pythonGH-104996: Implement path joining algorithm in pathlib
Merge branch 'main' into pythongh-104996-pathlib-fast-join
Merge branch 'main' into pythongh-104996-pathlib-fast-join