]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.12] GH-105113: Improve performance of `pathlib.PurePath.match()` (GH-105114)
authorBarney Gale <barney.gale@gmail.com>
Wed, 31 May 2023 20:37:37 +0000 (21:37 +0100)
committerGitHub <noreply@github.com>
Wed, 31 May 2023 20:37:37 +0000 (21:37 +0100)
commite7cb216339e8aa8d00f7f55f9e37864b1720ca0f
tree51cf3d735a04925c12f5d276c52153477345965c
parent076f3cda140a45b08c2c9518bc19624aae50d3a3
[3.12] GH-105113: Improve performance of `pathlib.PurePath.match()` (GH-105114)

We now compile a `re.Pattern` object for the entire pattern. This is made
more difficult by `fnmatch` not treating directory separators as special
when evaluating wildcards (`*`, `?`, etc), and so we arrange the path parts
onto separate *lines* in a string, and ensure we don't set `re.DOTALL`.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Doc/library/pathlib.rst
Lib/pathlib.py
Misc/NEWS.d/next/Library/2023-05-30-21-27-41.gh-issue-105113.bDUPl_.rst [new file with mode: 0644]