Title: GH-102613: Improve performance of `pathlib.Path.rglob()` by barneygale · Pull Request #104244 · python/cpython · GitHub
Open Graph Title: GH-102613: Improve performance of `pathlib.Path.rglob()` by barneygale · Pull Request #104244 · python/cpython
X Title: GH-102613: Improve performance of `pathlib.Path.rglob()` by barneygale · Pull Request #104244 · python/cpython
Description: Stop de-duplicating results in _RecursiveWildcardSelector. A new _DoubleRecursiveWildcardSelector class is introduced which performs de-duplication, but this is used only for patterns with multiple non-adjacent ** segments, such as path.glob('**/foo/**'). By avoiding the use of a set in most cases, PurePath.__hash__() is not called, and so paths do not need to be parsed and (case-) normalised. Also merge adjacent ** segments in patterns. Timings: $ ./python -m timeit -s 'from pathlib import Path; p = Path()' 'list(p.glob("**/*"))' 1 loop, best of 5: 197 msec per loop # before 2 loops, best of 5: 146 msec per loop # after --> 35% faster $ ./python -m timeit -s 'from pathlib import Path; p = Path()' 'list(p.glob("**/**/*"))' 1 loop, best of 5: 1.77 sec per loop # before 2 loops, best of 5: 146 msec per loop # after --> 12x faster $ ./python -m timeit -s 'from pathlib import Path; p = Path()' 'list(p.glob("**/*/**"))' 1 loop, best of 5: 738 msec per loop # before 1 loop, best of 5: 731 msec per loop # after --> about the same Issue: gh-102613
Open Graph Description: Stop de-duplicating results in _RecursiveWildcardSelector. A new _DoubleRecursiveWildcardSelector class is introduced which performs de-duplication, but this is used only for patterns with multiple...
X Description: Stop de-duplicating results in _RecursiveWildcardSelector. A new _DoubleRecursiveWildcardSelector class is introduced which performs de-duplication, but this is used only for patterns with multiple...
Opengraph URL: https://github.com/python/cpython/pull/104244
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:e35330e5-314f-1417-b104-cb71f7877dbc |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | DA30:D1023:119A1C1:17C2512:69699952 |
| html-safe-nonce | 91be46d1835e333188890b0e38e186fb9cd69fa47edc0ae0281ee0921ab32206 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQTMwOkQxMDIzOjExOUExQzE6MTdDMjUxMjo2OTY5OTk1MiIsInZpc2l0b3JfaWQiOiI3NTgxOTc1ODU4OTY4NjMxNjM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3d6e5e62c0a1e7b8e7cbc5f57199fa454eaa1be5ac3c4cfccbe64e1c057c8bc3 |
| hovercard-subject-tag | pull_request:1340878135 |
| 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/104244/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 | Stop de-duplicating results in _RecursiveWildcardSelector. A new _DoubleRecursiveWildcardSelector class is introduced which performs de-duplication, but this is used only for patterns with multiple... |
| 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