]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-115060: Speed up `pathlib.Path.glob()` by not scanning literal parts (#117732)
authorBarney Gale <barney.gale@gmail.com>
Fri, 12 Apr 2024 21:19:21 +0000 (22:19 +0100)
committerGitHub <noreply@github.com>
Fri, 12 Apr 2024 21:19:21 +0000 (22:19 +0100)
commit0eb52f5f266d9e0a662f28a4d2dfef8c746cf96e
tree2cccc9ca7a407f88e57b1bf1b7406a1c73005ce2
parent069de14cb948f56b37e507f367b99c5563d3685e
GH-115060: Speed up `pathlib.Path.glob()` by not scanning literal parts (#117732)

Don't bother calling `os.scandir()` to scan for literal pattern segments,
like `foo` in `foo/*.py`. Instead, append the segment(s) as-is and call
through to the next selector with `exists=False`, which signals that the
path might not exist. Subsequent selectors will call `os.scandir()` or
`os.lstat()` to filter out missing paths as needed.
Lib/glob.py
Lib/pathlib/_abc.py
Lib/test/test_pathlib/test_pathlib_abc.py
Misc/NEWS.d/next/Library/2024-04-10-22-35-24.gh-issue-115060.XEVuOb.rst [new file with mode: 0644]