Title: gh-137855: `email.quoprimime` removing `re` import by Marius-Juston · Pull Request #132046 · python/cpython · GitHub
Open Graph Title: gh-137855: `email.quoprimime` removing `re` import by Marius-Juston · Pull Request #132046 · python/cpython
X Title: gh-137855: `email.quoprimime` removing `re` import by Marius-Juston · Pull Request #132046 · python/cpython
Description: This pull request removes the re module from the email.quoprimime, thus increasing the import speed from 5676 us to 3669 us (a 60% import speed increase ); From marius@DESKTOP-IOUM5DH:~/cpython$ ./python -X importtime -c "import email.quoprimime" import time: self [us] | cumulative | imported package import time: 88 | 88 | _io import time: 19 | 19 | marshal import time: 143 | 143 | posix import time: 332 | 580 | _frozen_importlib_external import time: 42 | 42 | time import time: 125 | 166 | zipimport import time: 25 | 25 | _codecs import time: 290 | 315 | codecs import time: 190 | 190 | encodings.aliases import time: 417 | 921 | encodings import time: 90 | 90 | encodings.utf_8 import time: 44 | 44 | _signal import time: 22 | 22 | _abc import time: 93 | 114 | abc import time: 484 | 484 | _collections_abc import time: 136 | 733 | io import time: 22 | 22 | _stat import time: 59 | 80 | stat import time: 31 | 31 | errno import time: 43 | 43 | genericpath import time: 87 | 160 | posixpath import time: 283 | 523 | os import time: 50 | 50 | _sitebuiltins import time: 86 | 86 | sitecustomize import time: 30 | 30 | usercustomize import time: 216 | 902 | site import time: 114 | 114 | linecache import time: 203 | 203 | email import time: 22 | 22 | _string import time: 140 | 140 | types import time: 795 | 935 | enum import time: 34 | 34 | _sre import time: 130 | 130 | re._constants import time: 181 | 311 | re._parser import time: 49 | 49 | re._casefix import time: 198 | 591 | re._compiler import time: 57 | 57 | itertools import time: 75 | 75 | keyword import time: 41 | 41 | _operator import time: 153 | 194 | operator import time: 98 | 98 | reprlib import time: 32 | 32 | _collections import time: 553 | 1006 | collections import time: 30 | 30 | _functools import time: 346 | 1381 | functools import time: 95 | 95 | copyreg import time: 311 | 3311 | re import time: 365 | 3697 | string import time: 1777 | 5676 | email.quoprimime To marius@DESKTOP-IOUM5DH:~/cpython$ ./python -X importtime -c "import email.quoprimime" import time: self [us] | cumulative | imported package import time: 89 | 89 | _io import time: 18 | 18 | marshal import time: 130 | 130 | posix import time: 305 | 541 | _frozen_importlib_external import time: 37 | 37 | time import time: 115 | 152 | zipimport import time: 24 | 24 | _codecs import time: 273 | 296 | codecs import time: 175 | 175 | encodings.aliases import time: 387 | 857 | encodings import time: 83 | 83 | encodings.utf_8 import time: 40 | 40 | _signal import time: 16 | 16 | _abc import time: 88 | 103 | abc import time: 422 | 422 | _collections_abc import time: 125 | 649 | io import time: 20 | 20 | _stat import time: 54 | 73 | stat import time: 29 | 29 | errno import time: 39 | 39 | genericpath import time: 81 | 148 | posixpath import time: 269 | 490 | os import time: 48 | 48 | _sitebuiltins import time: 80 | 80 | sitecustomize import time: 28 | 28 | usercustomize import time: 199 | 842 | site import time: 106 | 106 | linecache import time: 189 | 189 | email import time: 18 | 18 | _string import time: 124 | 124 | types import time: 667 | 791 | enum import time: 33 | 33 | _sre import time: 130 | 130 | re._constants import time: 177 | 307 | re._parser import time: 49 | 49 | re._casefix import time: 179 | 566 | re._compiler import time: 58 | 58 | itertools import time: 74 | 74 | keyword import time: 36 | 36 | _operator import time: 148 | 183 | operator import time: 96 | 96 | reprlib import time: 31 | 31 | _collections import time: 494 | 934 | collections import time: 27 | 27 | _functools import time: 315 | 1274 | functools import time: 87 | 87 | copyreg import time: 284 | 3000 | re import time: 297 | 3314 | string import time: 168 | 3669 | email.quoprimime however, the new implementation does increase the compute time TEST_CASES = { "empty": "Dracula", "empty_medium": "Dracula"* 10, "empty_long": "Dracula"* 100, "short": "Hello=20World=21", "medium": "This_is_a_test=3F=3D=2E" * 10, "long": "Some_long_text_with_encoding=20" * 100, "mixed": "A=2Equick=20brown=5Ffox=21=3F" * 50, "edge_case_short": "=20=21=3F=2E=5F", "edge_case_long": "=20=21=3F=2E=5F" * 200 } Benchmark regex non_regex empty 284 ns 382 ns: 1.34x slower empty_medium 302 ns 2.99 us: 9.91x slower empty_long 371 ns 28.6 us: 77.20x slower short 731 ns 902 ns: 1.23x slower medium 6.24 us 11.8 us: 1.89x slower long 25.5 us 137 us: 5.37x slower mixed 57.0 us 71.5 us: 1.25x slower edge_case_short 1.36 us 916 ns: 1.48x faster edge_case_long 178 us 160 us: 1.11x faster Geometric mean (ref) 2.78x slower So it is very possible that this is not worth it. Issues: gh-130167 gh-118761 Issue: gh-137855
Open Graph Description: This pull request removes the re module from the email.quoprimime, thus increasing the import speed from 5676 us to 3669 us (a 60% import speed increase ); From marius@DESKTOP-IOUM5DH:~/cpython$ ./...
X Description: This pull request removes the re module from the email.quoprimime, thus increasing the import speed from 5676 us to 3669 us (a 60% import speed increase ); From marius@DESKTOP-IOUM5DH:~/cpython$ ./...
Opengraph URL: https://github.com/python/cpython/pull/132046
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:751b5284-0638-4051-8f53-a27be996e420 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AFB4:1EEB64:117A200:17FE202:6969F85E |
| html-safe-nonce | b38ca7269bbf334311114f1e3a1d4ed6893f788000bdd602936ece81d9148e69 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkI0OjFFRUI2NDoxMTdBMjAwOjE3RkUyMDI6Njk2OUY4NUUiLCJ2aXNpdG9yX2lkIjoiMzg4MTU2MzAyNDY0NzY0OTM3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bdca770ec1073ca7002f7157d9314edcce398d8fc42c325bd00534761b2c7e42 |
| hovercard-subject-tag | pull_request:2436592272 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/132046/files |
| 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 | This pull request removes the re module from the email.quoprimime, thus increasing the import speed from 5676 us to 3669 us (a 60% import speed increase ); From marius@DESKTOP-IOUM5DH:~/cpython$ ./... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width