]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-115060: Speed up `pathlib.Path.glob()` by removing redundant regex matching (...
authorBarney Gale <barney.gale@gmail.com>
Sat, 10 Feb 2024 18:12:34 +0000 (18:12 +0000)
committerGitHub <noreply@github.com>
Sat, 10 Feb 2024 18:12:34 +0000 (18:12 +0000)
commit6f93b4df92b8fbf80529cb6435789f5a75664a20
tree9847e44bb89c24c38f5217dada3fdfc83344a376
parent9d1a353230f555fc28239c5ca1e82b758084e02a
GH-115060: Speed up `pathlib.Path.glob()` by removing redundant regex matching (#115061)

When expanding and filtering paths for a `**` wildcard segment, build an `re.Pattern` object from the subsequent pattern parts, rather than the entire pattern, and match against the `os.DirEntry` object prior to instantiating a path object. Also skip compiling a pattern when expanding a `*` wildcard segment.
Lib/pathlib/__init__.py
Lib/pathlib/_abc.py
Lib/test/test_pathlib/test_pathlib.py
Misc/NEWS.d/next/Library/2024-02-06-03-55-46.gh-issue-115060.EkWRpP.rst [new file with mode: 0644]