Title: gh-130167: Minor `textwrap.dedent()` optimization by Marius-Juston · Pull Request #131925 · python/cpython · GitHub
Open Graph Title: gh-130167: Minor `textwrap.dedent()` optimization by Marius-Juston · Pull Request #131925 · python/cpython
X Title: gh-130167: Minor `textwrap.dedent()` optimization by Marius-Juston · Pull Request #131925 · python/cpython
Description: Minor optimization to @AA-Turner #131792 where you compute the min and max of the non_blank_lines simultaneously, removes additional use of line.isspace() as well. Benchmark raw new raw_text: "abc \t" 2.91 ms 3.33 ms: 1.15x slower raw_text: " " 4.31 ms 4.17 ms: 1.03x faster raw_text: " \t abc" 4.04 ms 4.40 ms: 1.09x slower raw_text: " \t abc \t " 4.08 ms 4.40 ms: 1.08x slower raw_text: 1000 spaces 34.9 ms 27.9 ms: 1.25x faster Basic indented text with empty lines 1.88 us 1.82 us: 1.03x faster Text with mixed indentation and blank lines 1.85 us 1.79 us: 1.03x faster No indentation (edge case) 1.24 us 1.14 us: 1.09x faster Only blank lines 958 ns 641 ns: 1.49x faster Edge case: No common prefix to remove 1.09 us 993 ns: 1.10x faster Edge case: Single indented line 998 ns 855 ns: 1.17x faster Edge case: Single indented line only 631 ns 432 ns: 1.46x faster Edge case: Empty text 89.3 ns 81.0 ns: 1.10x faster no_indent 2.57 us 2.50 us: 1.03x faster mixed 10.4 us 10.9 us: 1.05x slower large_text 77.7 us 85.7 us: 1.10x slower whitespace_only 859 ns 599 ns: 1.43x faster Geometric mean (ref) 1.08x faster Issue: gh-130167
Open Graph Description: Minor optimization to @AA-Turner #131792 where you compute the min and max of the non_blank_lines simultaneously, removes additional use of line.isspace() as well. Benchmark raw new raw_tex...
X Description: Minor optimization to @AA-Turner #131792 where you compute the min and max of the non_blank_lines simultaneously, removes additional use of line.isspace() as well. Benchmark raw new raw_tex...
Opengraph URL: https://github.com/python/cpython/pull/131925
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:873eb48c-4156-1f0e-8052-a30f2bbd2c9f |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C688:D09C0:5BC30:74BA8:696AF201 |
| html-safe-nonce | 223024c8c1bb1cfb7bf25ae48359d0e64afc3205331b76686adafac7cb582504 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjg4OkQwOUMwOjVCQzMwOjc0QkE4OjY5NkFGMjAxIiwidmlzaXRvcl9pZCI6IjM1NTA1MDE3MTg0OTY4MzQwNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d1e29ca6a4c606f8db43e6b5482048bd2ab60bb50785ba277bf90f9906113794 |
| hovercard-subject-tag | pull_request:2427894371 |
| 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/131925/checks |
| twitter:image | https://avatars.githubusercontent.com/u/19751068?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/19751068?s=400&v=4 |
| og:image:alt | Minor optimization to @AA-Turner #131792 where you compute the min and max of the non_blank_lines simultaneously, removes additional use of line.isspace() as well. Benchmark raw new raw_tex... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-cache |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width