Title: GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` by barneygale · Pull Request #101398 · python/cpython · GitHub
Open Graph Title: GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` by barneygale · Pull Request #101398 · python/cpython
X Title: GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` by barneygale · Pull Request #101398 · python/cpython
Description: PurePath.match() now handles the ** wildcard as in Path.glob(), i.e. it matches any number of path segments. 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. This improves performance of match() around 2x-3x times for simple patterns, and more for complex patterns: $ ./python -m timeit \ -s 'from pathlib import PureWindowsPath as P; path = P("C:/foo/bar.py"); pattern = P("c:/*/*.py")' \ 'path.match(pattern)' 50000 loops, best of 5: 8.13 usec per loop # before 1000000 loops, best of 5: 297 nsec per loop # after Issue: gh-73435
Open Graph Description: PurePath.match() now handles the ** wildcard as in Path.glob(), i.e. it matches any number of path segments. We now compile a re.Pattern object for the entire pattern. This is made more difficult b...
X Description: PurePath.match() now handles the ** wildcard as in Path.glob(), i.e. it matches any number of path segments. We now compile a re.Pattern object for the entire pattern. This is made more difficult b...
Opengraph URL: https://github.com/python/cpython/pull/101398
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:4d358f7a-ac67-635d-f8fd-e55705f0256d |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C4A8:10CAF0:AA0741:E38B7D:69699356 |
| html-safe-nonce | 6d71a9e09c24d0ed4135bbea67b8cbd56a625b5967adc8f1bb4aa2036c3f2dfa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNEE4OjEwQ0FGMDpBQTA3NDE6RTM4QjdEOjY5Njk5MzU2IiwidmlzaXRvcl9pZCI6IjMxMzU4OTg3Mjg1OTM0NjIxMDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e147d5f9282b11a65f775bee047775e19a9970f9ff377695530d013f20d18faa |
| hovercard-subject-tag | pull_request:1220404903 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/101398/checks |
| twitter:image | https://avatars.githubusercontent.com/u/960340?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/960340?s=400&v=4 |
| og:image:alt | PurePath.match() now handles the ** wildcard as in Path.glob(), i.e. it matches any number of path segments. We now compile a re.Pattern object for the entire pattern. This is made more difficult b... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width