| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
|
Sorry but I'm closing, the issue author asked to open the PR, please read the issue before opening. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #159717.
Thanks to @digit50 for the original report and reproducer.
glob.translate() currently discards the star positions returned by fnmatch._translate(). As a result, short patterns such as '*a' * 8 + '*b' repeatedly backtrack in PurePath.match(), PurePath.full_match() and Path.glob().
Reuse the atomic-star joining logic for each ordinary glob segment, with a separator-excluding star. Keep the existing fast path for segments with fewer than two stars, and leave recursive ** and hidden-name handling in glob. fnmatch.translate() retains its existing public regex output.
A fixed part that can consume a separator must remain backtrackable: for example, *[!x]*x currently matches a/x. The separator check also covers case-sensitive and case-insensitive uses with custom separators. This patch preserves that behavior instead of changing character-class semantics as a side effect.
Validation on Windows x64, a Debug build of main at 4c73f50ca9885e5850dae64463e87cf5e80992a1:
For the issue's pattern against 36 a characters, the same Debug interpreter measured full_match at about 631 ms before and 0.096 ms after, and a single-file Path.glob at about 1706 ms before and 0.342 ms after. These are warmed-up medians of three calls for this reproducer, not a general performance claim.
This does not promise to remove all backtracking involving recursive patterns or character classes that consume separators. Cold translation of multi-star patterns has some additional cost; the change targets excessive matching cost and retains the common zero/one-star translation path.
Prepared with OpenAI Codex assistance for implementation, test generation and review. Builds, tests and measurements were executed locally.