Feature or enhancement
Return an unnormalized path from pathlib.PurePath.__fspath__()
Pitch
Code like open(Path('./README.txt')) or Path('/home//barney').iterdir() shouldn't require us to normalize the path in pathlib (e.g. remove . segments, doubled slashes, etc), as OS APIs are perfectly happy with unnormalized paths.
We can improve the performance of most Path methods, and the effective performance of passing a Path object to any API that accepts os.PathLike, by skipping normalization in __fspath__().
Prerequisites
Pathlib must not normalize paths on construction:
Pathlib's normalization must not change the meaning of paths:
Previous discussion
Linked PRs
Feature or enhancement
Return an unnormalized path from
pathlib.PurePath.__fspath__()Pitch
Code like
open(Path('./README.txt'))orPath('/home//barney').iterdir()shouldn't require us to normalize the path in pathlib (e.g. remove.segments, doubled slashes, etc), as OS APIs are perfectly happy with unnormalized paths.We can improve the performance of most
Pathmethods, and the effective performance of passing aPathobject to any API that acceptsos.PathLike, by skipping normalization in__fspath__().Prerequisites
Pathlib must not normalize paths on construction:
Pathlib's normalization must not change the meaning of paths:
Previous discussion
Linked PRs
pathlib.PurePath.__fspath__()by returning raw path #112397