Title: Improve import time of various stdlib modules · Issue #118761 · python/cpython · GitHub
Open Graph Title: Improve import time of various stdlib modules · Issue #118761 · python/cpython
X Title: Improve import time of various stdlib modules · Issue #118761 · python/cpython
Description: Feature or enhancement Proposal: Following on from #109653, further improvements can be made to import times. Links to previous discussion of this feature: https://discuss.python.org/t/deferred-computation-evalution-for-toplevels-imports...
Open Graph Description: Feature or enhancement Proposal: Following on from #109653, further improvements can be made to import times. Links to previous discussion of this feature: https://discuss.python.org/t/deferred-com...
X Description: Feature or enhancement Proposal: Following on from #109653, further improvements can be made to import times. Links to previous discussion of this feature: https://discuss.python.org/t/deferred-com...
Opengraph URL: https://github.com/python/cpython/issues/118761
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve import time of various stdlib modules","articleBody":"# Feature or enhancement\r\n\r\n### Proposal:\r\n\r\nFollowing on from https://github.com/python/cpython/issues/109653, further improvements can be made to import times.\r\n\r\n### Links to previous discussion of this feature:\r\n\r\nhttps://discuss.python.org/t/deferred-computation-evalution-for-toplevels-imports-and-dataclasses/34173\r\n\r\n### For example:\r\n\r\n`importlib.metadata` is often used for tasks that need to happen at import, e.g. to enumerate/load entry point plug-ins, so it might be worth seeing if we can cut down its own import time a bit more.\r\n\r\n`importlib.metadata` imports `zipfile` at the top for a function that won't be called in the vast majority of cases. It also imports `importlib.abc`, which in turn imports `importlib.resources`, to subclass an ABC with a single, non-abstract method - I assume redefining the method in `importlib.metadata` would be harmless. Some other less frequently-used imports which are only accessed once or twice, such as `json`, could also be tucked away in their calling functions.\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-122725\n* gh-123520\n* gh-121424\n* gh-126979\n* gh-128732\n* gh-128736\n* gh-128738\n* gh-128858\n* gh-128898\n* gh-128899\n* gh-128907\n* gh-128981\n* gh-129118\n* gh-129427\n* gh-129428\n* gh-129447\n* gh-129448\n* gh-129765\n* gh-129811\n* gh-129860\n* gh-129925\n* gh-130056\n* gh-130201\n* gh-130204\n* gh-130205\n* gh-131796\n* gh-131953\n* gh-131956\n* gh-132024\n* gh-132025\n* gh-132028\n* gh-132031\n* gh-132035\n* gh-132036\n* gh-132037\n* gh-132046\n* gh-132059\n* gh-132060\n* gh-132103\n* gh-132614\n* gh-133057\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/layday","@type":"Person","name":"layday"},"datePublished":"2024-05-08T13:13:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":71},"url":"https://github.com/118761/cpython/issues/118761"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:239dc11e-5b3e-f4cc-4678-ae838adf81fe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6BA:2D0DCE:702A2:9A144:696962E2 |
| html-safe-nonce | 29eeaaf6a9546ec5e5af58810ce61892ee274f079f26d15d0d8200e5e9994abd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkJBOjJEMERDRTo3MDJBMjo5QTE0NDo2OTY5NjJFMiIsInZpc2l0b3JfaWQiOiI1ODc1MDc4NjkyMTU1Nzc3NzYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3af456fd647243f8a7f70f4a6f252f56f71a97ce4943afd97f947499ba2fa7ad |
| hovercard-subject-tag | issue:2285570381 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/118761/issue_layout |
| twitter:image | https://opengraph.githubassets.com/17b571672495cd1a315e85a9b64d8bf0a450203ae0cc58e40b2dfc74f09450bc/python/cpython/issues/118761 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/17b571672495cd1a315e85a9b64d8bf0a450203ae0cc58e40b2dfc74f09450bc/python/cpython/issues/118761 |
| og:image:alt | Feature or enhancement Proposal: Following on from #109653, further improvements can be made to import times. Links to previous discussion of this feature: https://discuss.python.org/t/deferred-com... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | layday |
| hostname | github.com |
| expected-hostname | github.com |
| None | 48487c1ad776a7975b7132d95f4240ff3ae37cd5b8e3cb597102a4edb76738f1 |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 669463fcc54773a88c1f5a44eef6b99a5504b9c7 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width