Title: gh-109653: Defer importing `warnings` in several modules by AlexWaygood · Pull Request #110286 · python/cpython · GitHub
Open Graph Title: gh-109653: Defer importing `warnings` in several modules by AlexWaygood · Pull Request #110286 · python/cpython
X Title: gh-109653: Defer importing `warnings` in several modules by AlexWaygood · Pull Request #110286 · python/cpython
Description: warnings is a pretty cheap import, so the import-time saving from deferring it is usually pretty minimal. However, it's also a textbook example of an import that should be deferred wherever reasonable. Most of the time, it's only imported so that a DeprecationWarning can be emitted, and we should try to make it so that users only have to pay the (small) performance penalty from it being imported if they actually hit the specific code path that's deprecated. Nonetheless, since the performance impact of importing warnings is so small, I've tried to avoid modules that make multiple uses of warnings -- it's not particularly DRY to have import warnings repeated several times in the same module. The one exception I made here is argparse: argparse really should be importing the absolute minimum set of modules given that it's a CLI framework (see #74338 for previous discussion). Issue: gh-109653
Open Graph Description: warnings is a pretty cheap import, so the import-time saving from deferring it is usually pretty minimal. However, it's also a textbook example of an import that should be deferred wherever rea...
X Description: warnings is a pretty cheap import, so the import-time saving from deferring it is usually pretty minimal. However, it's also a textbook example of an import that should be deferred wherever...
Opengraph URL: https://github.com/python/cpython/pull/110286
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:fad5bf56-9da2-cd95-75e2-459380d28292 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 98DE:37464F:4C98DC:6C68B5:696A0CCF |
| html-safe-nonce | 8777958efe5a26943abced0890c29d1960c355d676b7283c13974636487a8a58 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OERFOjM3NDY0Rjo0Qzk4REM6NkM2OEI1OjY5NkEwQ0NGIiwidmlzaXRvcl9pZCI6Ijc4ODMxMjAwODkzODI5MTUyNzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7255569f6c0ec4028685b7dd45399e2c76d1420b72f66981c5ea331998f3d21f |
| hovercard-subject-tag | pull_request:1540101347 |
| 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/110286/checks |
| twitter:image | https://avatars.githubusercontent.com/u/66076021?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/66076021?s=400&v=4 |
| og:image:alt | warnings is a pretty cheap import, so the import-time saving from deferring it is usually pretty minimal. However, it's also a textbook example of an import that should be deferred wherever rea... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595 |
| 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 | 7266b2d935baa1c6474b16dd9feaa5ca30607261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width