Title: Lazily import `traceback` in `logging` · Issue #150072 · python/cpython · GitHub
Open Graph Title: Lazily import `traceback` in `logging` · Issue #150072 · python/cpython
X Title: Lazily import `traceback` in `logging` · Issue #150072 · python/cpython
Description: Feature or enhancement Proposal: Currently, Lib/logging/__init__.py and Lib/logging/config.py eagerly import traceback, despite it only being used during exception handling. Making this import lazy avoids unnecessary startup overhead and...
Open Graph Description: Feature or enhancement Proposal: Currently, Lib/logging/__init__.py and Lib/logging/config.py eagerly import traceback, despite it only being used during exception handling. Making this import lazy...
X Description: Feature or enhancement Proposal: Currently, Lib/logging/__init__.py and Lib/logging/config.py eagerly import traceback, despite it only being used during exception handling. Making this import lazy...
Opengraph URL: https://github.com/python/cpython/issues/150072
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Lazily import `traceback` in `logging`","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nCurrently, `Lib/logging/__init__.py` and `Lib/logging/config.py` eagerly import `traceback`, despite it only being used during exception handling. Making this import lazy avoids unnecessary startup overhead and improves initial loading time.\n\u003ctable>\n\u003ctr>\n\u003cth>Before 41ms\u003cimg width=\"2398\" height=\"1494\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/4b4aabd2-cd7d-4408-a610-ba3711538286\" />\u003c/th>\n\u003cth>After 28ms(~31% faster)\u003cimg width=\"2398\" height=\"1494\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/0abe1370-332d-4579-8b24-ad578581dd20\" />\u003c/th>\n\u003c/tr>\n\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-150073\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/IvyXu420","@type":"Person","name":"IvyXu420"},"datePublished":"2026-05-19T10:37:12Z","url":"https://github.com/python/cpython/issues/150072"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:1328fc67-e5f9-053b-5ddf-f5149ad5e551 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB38:EAD6D:2BBA0D:370EC3:6B020741 |
| html-safe-nonce | 45a68867ec5c7ff7b4db4979e399098d5fb48effceea2d2673c849c04cdf669a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjM4OkVBRDZEOjJCQkEwRDozNzBFQzM6NkIwMjA3NDEiLCJ2aXNpdG9yX2lkIjoiODg3MTA5NjAzNzg5MzM0MzA0MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7784a73804479fbe0e6b4d240e26730f9abe7cc385b99ddfcb8bf14f0efb58cd |
| hovercard-subject-tag | issue:4476633434 |
| 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/150072/issue_layout |
| twitter:image | https://opengraph.githubassets.com/be58b353b90462138f0a0b7d6ffee342df53143e7acc93fa44f5707ec80cacde/python/cpython/issues/150072 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/be58b353b90462138f0a0b7d6ffee342df53143e7acc93fa44f5707ec80cacde/python/cpython/issues/150072 |
| og:image:alt | Feature or enhancement Proposal: Currently, Lib/logging/__init__.py and Lib/logging/config.py eagerly import traceback, despite it only being used during exception handling. Making this import lazy... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | IvyXu420 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width