René's URL Explorer Experiment


Title: Inspect module is prohibitively expensive to import · Issue #117865 · python/cpython · GitHub

Open Graph Title: Inspect module is prohibitively expensive to import · Issue #117865 · python/cpython

X Title: Inspect module is prohibitively expensive to import · Issue #117865 · python/cpython

Description: From post by @AlexWaygood in #117372 (comment)_: I'm a little dismayed that dataclasses adds so much overhead. Does that imply that dataclasses shouldn't be used in the stdlib? dataclasses is an unfortunately heavy import, yes. Although ...

Open Graph Description: From post by @AlexWaygood in #117372 (comment)_: I'm a little dismayed that dataclasses adds so much overhead. Does that imply that dataclasses shouldn't be used in the stdlib? dataclasses is an un...

X Description: From post by @AlexWaygood in #117372 (comment)_: I'm a little dismayed that dataclasses adds so much overhead. Does that imply that dataclasses shouldn't be used in the stdlib? dataclasses ...

Opengraph URL: https://github.com/python/cpython/issues/117865

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inspect module is prohibitively expensive to import","articleBody":"From post by @AlexWaygood in https://github.com/python/cpython/issues/117372#issuecomment-2047024740_:\r\n\r\n> > I'm a little dismayed that dataclasses adds so much overhead. Does that imply that dataclasses shouldn't be used in the stdlib?\r\n>\r\n> `dataclasses` is an unfortunately heavy import, yes. Although it imports relatively few modules itself, one of those modules is `inspect`, which has a _huge_ import time (`inspect` imports half the standard library). In the past, I've looked into removing the `dataclasses` dependency on `inspect`, but couldn't see a way to do so without making the code significantly more ugly; the same goes when it comes to improving the import time for `inspect` itself. (In hindsight, I'd argue `inspect` should probably have been a package rather than a huge single-file Python module... but hindsight is 20/20.)\r\n\r\nPerhaps inspect could be refactored to limit the import-time cost.\r\n\r\nCurrently on my m3 mac pro, on the second attempt, the import times are 1.2ms and 7.9ms (cumulative):\r\n\r\n```\r\n cpython main @ ./python.exe -X importtime -c 'import inspect' 2> /dev/null ; ./python.exe -X importtime -c 'import inspect' 2>1 | grep -E '(cumul|inspect)'\r\nimport time: self [us] | cumulative | imported package\r\nimport time:      1184 |       7892 | inspect\r\n```\r\n\r\nI've searched the issue tracker and didn't see anything tracking this concern, so right now it's a naïve feature request.\r\n\r\nRelated: https://github.com/python/cpython/issues/108901\r\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-119526\n* gh-119546\n* gh-144756\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/jaraco","@type":"Person","name":"jaraco"},"datePublished":"2024-04-14T10:27:22Z","url":"https://github.com/python/cpython/issues/117865"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:087abef8-3ef8-05cd-0781-17dc6851d0eb
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id95E0:1D86C4:3DF0121:4EAC959:6B020F6F
html-safe-nonce4071029dbdf3860621dbab9c1b5acd2240bf516f523d5ec135338debf61ce930
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUUwOjFEODZDNDozREYwMTIxOjRFQUM5NTk6NkIwMjBGNkYiLCJ2aXNpdG9yX2lkIjoiMjE0NzYzNDk0ODYwODIzMzMyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac632f407f3918db1c139e64bf66f6c34f5aab7904a6ea5be38434c59af861dbb5
hovercard-subject-tagissue:2242086904
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/117865/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c7c6c31b5a9a1fe309f5258ddc6336568afaad3b14d3e0cfec0335f7af45c99a/python/cpython/issues/117865
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c7c6c31b5a9a1fe309f5258ddc6336568afaad3b14d3e0cfec0335f7af45c99a/python/cpython/issues/117865
og:image:altFrom post by @AlexWaygood in #117372 (comment)_: I'm a little dismayed that dataclasses adds so much overhead. Does that imply that dataclasses shouldn't be used in the stdlib? dataclasses is an un...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejaraco
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/117865#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F117865
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F117865
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/117865
Reloadhttps://github.com/python/cpython/issues/117865
Reloadhttps://github.com/python/cpython/issues/117865
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/117865
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/117865
Inspect module is prohibitively expensive to importhttps://github.com/python/cpython/issues/117865#top
performancePerformance or resource usagehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22performance%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issue-2242086904
@AlexWaygoodhttps://github.com/AlexWaygood
#117372 (comment)https://github.com/python/cpython/pull/117372#issuecomment-2047024740
#108901https://github.com/python/cpython/issues/108901
gh-117865: Defer several imports in inspect.py #119526https://github.com/python/cpython/pull/119526
gh-117865: Defer import of re in ast #119546https://github.com/python/cpython/pull/119546
gh-117865: Speedup import of inspect module #144756https://github.com/python/cpython/pull/144756
https://github.com/jaraco
jaracohttps://github.com/jaraco
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054000319
AlexWaygoodhttps://github.com/AlexWaygood
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
performancePerformance or resource usagehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22performance%22
on Apr 14, 2024https://github.com/python/cpython/issues/117865#event-12460085891
https://github.com/hugovk
hugovkhttps://github.com/hugovk
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054018179
https://github.com/nschloe/tunahttps://github.com/nschloe/tuna
https://private-user-images.githubusercontent.com/1324225/322269391-c4c8e48f-7f3e-4c56-9001-11ff2e064217.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUyOTc0MzUsIm5iZiI6MTc5NTI5NzEzNSwicGF0aCI6Ii8xMzI0MjI1LzMyMjI2OTM5MS1jNGM4ZTQ4Zi03ZjNlLTRjNTYtOTAwMS0xMWZmMmUwNjQyMTcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEyMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMjFUMjEzODU1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDY3ODZkZjE3N2M5MDI5MzFlYmMyZGFmYjkxYjY3N2FlMGFlYzcwMjRjOGNiOTVjZTllMWZhZGQ4N2EzNjBmNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.v0G9IsOChy_cMVxi4pQBqcbO01BGyUDJTnjDtAAgwT8
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054070824
https://docs.python.org/3.10/library/ast.html#ast.get_source_segmenthttps://docs.python.org/3.10/library/ast.html#ast.get_source_segment
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054072786
https://github.com/JelleZijlstra
JelleZijlstrahttps://github.com/JelleZijlstra
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054080489
https://github.com/hugovk
hugovkhttps://github.com/hugovk
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054089372
tokenizehttps://github.com/python/cpython/blob/main/Lib/tokenize.py
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Apr 14, 2024https://github.com/python/cpython/issues/117865#issuecomment-2054091108
#104719https://github.com/python/cpython/issues/104719
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Apr 16, 2024https://github.com/python/cpython/issues/117865#issuecomment-2058944719
https://github.com/DavidCEllis
DavidCEllishttps://github.com/DavidCEllis
on Apr 19, 2024https://github.com/python/cpython/issues/117865#issuecomment-2067210927
1https://github.com/python/cpython/issues/117865#user-content-fn-1-d8d5c510b488dbc281a44f1ee6321500
2https://github.com/python/cpython/issues/117865#user-content-fn-2-d8d5c510b488dbc281a44f1ee6321500
↩https://github.com/python/cpython/issues/117865#user-content-fnref-1-d8d5c510b488dbc281a44f1ee6321500
↩https://github.com/python/cpython/issues/117865#user-content-fnref-2-d8d5c510b488dbc281a44f1ee6321500
serhiy-storchakahttps://github.com/serhiy-storchaka
Inspect issues 🔍https://github.com/orgs/python/projects/45
on Apr 30, 2024https://github.com/python/cpython/issues/117865#event-14872616728
JelleZijlstrahttps://github.com/JelleZijlstra
on May 25, 2024https://github.com/python/cpython/issues/117865#event-12933138183
pythongh-117865: Defer import of re in asthttps://github.com/JelleZijlstra/cpython/commit/9cbb64cf8a850dafebf68abb16a9cb9b12db247c
pythongh-117865https://github.com/python/cpython/issues/117865
9cbb64chttps://github.com/JelleZijlstra/cpython/commit/9cbb64cf8a850dafebf68abb16a9cb9b12db247c
gh-117865: Defer import of re in ast (#119546)https://github.com/python/cpython/commit/ae11d68ab90324a3359699ca13fcf9a229966713
gh-117865https://github.com/python/cpython/issues/117865
#119546https://github.com/python/cpython/pull/119546
ae11d68https://github.com/python/cpython/commit/ae11d68ab90324a3359699ca13fcf9a229966713
estyxxhttps://github.com/estyxx
on Jul 17, 2024https://github.com/python/cpython/issues/117865#event-13533252700
pythongh-117865: Defer import of re in ast (python#119546)https://github.com/estyxx/cpython/commit/75e2276c29010a8609e1350a6d3861341b3533a5
pythongh-117865https://github.com/python/cpython/issues/117865
python#119546https://github.com/python/cpython/pull/119546
75e2276https://github.com/estyxx/cpython/commit/75e2276c29010a8609e1350a6d3861341b3533a5
hugovkhttps://github.com/hugovk
on Mar 2, 2026https://github.com/python/cpython/issues/117865#event-23206634397
gh-117865: Speedup import of `inspect` module (#144756)https://github.com/python/cpython/commit/ea90b032a016122e7871e91c5210f3b4e68768b4
gh-117865https://github.com/python/cpython/issues/117865
#144756https://github.com/python/cpython/pull/144756
ea90b03https://github.com/python/cpython/commit/ea90b032a016122e7871e91c5210f3b4e68768b4
ljfphttps://github.com/ljfp
on Apr 25, 2026https://github.com/python/cpython/issues/117865#event-24868321859
pythongh-117865: Speedup import of `inspect` module (python#144756)https://github.com/ljfp/cpython/commit/9d828a003ef350b6d6ed3e0f567449e51aee0f7a
pythongh-117865https://github.com/python/cpython/issues/117865
python#144756https://github.com/python/cpython/pull/144756
9d828a0https://github.com/ljfp/cpython/commit/9d828a003ef350b6d6ed3e0f567449e51aee0f7a
https://github.com/danielhollas
danielhollashttps://github.com/danielhollas
on May 1, 2026https://github.com/python/cpython/issues/117865#issuecomment-4361342356
#144756https://github.com/python/cpython/pull/144756
#137855https://github.com/python/cpython/issues/137855
https://github.com/danielhollas
danielhollashttps://github.com/danielhollas
on May 1, 2026https://github.com/python/cpython/issues/117865#issuecomment-4361355834
#144756https://github.com/python/cpython/pull/144756
https://private-user-images.githubusercontent.com/9539441/586622624-4c3a545a-3feb-4430-8efe-df0a48d7a24c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3OTUyOTc0MzUsIm5iZiI6MTc5NTI5NzEzNSwicGF0aCI6Ii85NTM5NDQxLzU4NjYyMjYyNC00YzNhNTQ1YS0zZmViLTQ0MzAtOGVmZS1kZjBhNDhkN2EyNGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MTEyMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjExMjFUMjEzODU1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzY2ODkwYmU2OWMxMjhkMWVmNmIyMjgxM2ViYmY3ZDE5MDU1YWNjMzFiMmNhYThkODNhOTkxNDliZWFhMWVkZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmcmVzcG9uc2UtY29udGVudC10eXBlPWltYWdlJTJGcG5nIn0.eMDTF2YOWt45ExXAu9746CNzJjo6GbdbrzF43_vpfBc
hugovkhttps://github.com/hugovk
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 23, 2026https://github.com/python/cpython/issues/117865#event-34054256845
github-project-automationhttps://github.com/apps/github-project-automation
Inspect issues 🔍https://github.com/orgs/python/projects/45
on Oct 23, 2026https://github.com/python/cpython/issues/117865
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/117865
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/117865
performancePerformance or resource usagehttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22performance%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
Inspect issues 🔍https://github.com/orgs/python/projects/45
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.