]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-102613: Improve performance of `pathlib.Path.rglob()` (GH-104244)
authorBarney Gale <barney.gale@gmail.com>
Sun, 7 May 2023 21:12:50 +0000 (22:12 +0100)
committerGitHub <noreply@github.com>
Sun, 7 May 2023 21:12:50 +0000 (22:12 +0100)
commitc0ece3dc9791694e960952ba74070efaaa79a676
tree17d6baebf2f6a39e129b7e74da2ab56a029e8d16
parent8d95012c95988dc517db6e09348aab996868699c
GH-102613: Improve performance of `pathlib.Path.rglob()` (GH-104244)

Stop de-duplicating results in `_RecursiveWildcardSelector`. A new
`_DoubleRecursiveWildcardSelector` class is introduced which performs
de-duplication, but this is used _only_ for patterns with multiple
non-adjacent `**` segments, such as `path.glob('**/foo/**')`. By avoiding
the use of a set, `PurePath.__hash__()` is not called, and so paths do not
need to be stringified and case-normalised.

Also merge adjacent '**' segments in patterns.
Lib/pathlib.py
Lib/test/test_pathlib.py
Misc/NEWS.d/next/Library/2023-05-06-20-37-46.gh-issue-102613.QZG9iX.rst [new file with mode: 0644]