Closed
Description
Pathlib is slow. One of the most obvious symptoms is that pathlib.PurePath
objects are slow to construct. We should be able to speed construction up without making other parts of pathlib slower.
Two possible approaches:
- Optimize the existing machinary of path construction:
__new__()
,_from_parts()
,_parse_parts()
,_parse_args()
. - Perform less work in the constructor: defer parsing, joining and normalization until needed.
Linked PRs
- GH-101362: Optimise pathlib by deferring path normalisation #101560
- GH-101362: Check pathlib.Path flavour compatibility at import time #101664
- GH-101362: Call join() only when >1 argument supplied to pathlib.PurePath() #101665
- GH-101362: Optimise PurePath(PurePath(...)) #101667
- GH-101362: Omit path anchor from
pathlib.PurePath()._parts
#102476