Closed
Labels
3.13only security fixesonly security fixesperformancePerformance or resource usagePerformance or resource usagetopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement
Description
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
- (Maybe) re-implementing
os.path.join(), as pathlib did before gh-94909: fix joining of absolute and relative Windows paths in pathlib #95450.
Linked PRs
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixesperformancePerformance or resource usagePerformance or resource usagetopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement
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