René's URL Explorer Experiment


Title: gh-121954: Don't mutate tuples in _PyCode_New by encukou · Pull Request #122180 · python/cpython · GitHub

Open Graph Title: gh-121954: Don't mutate tuples in _PyCode_New by encukou · Pull Request #122180 · python/cpython

X Title: gh-121954: Don't mutate tuples in _PyCode_New by encukou · Pull Request #122180 · python/cpython

Description: Change _PyCode_New (intern_strings & intern_constants) to return new tuples rather than mutating their arguments. If possible, return the argument rather than create a copy. In order to make copying less common, intern strings destined for _PyCode_New earlier -- in: _PyCode_ConstantKey, used in the compiler to de-duplicate constants; symtable_implicit_arg, which generates the names .0, .1 etc. The most common implicit arg, .0, is baked in as a _Py_STR others are immortalized This means all string constants produced by the compiler are interned; previously it was only names and identifier-like strings. (We already hash all code constants in order to de-duplicate them, and we treat deleting code objects as rare event. Also, constants were interned in the free-threaded build.) Remove a test that verified a string constant is not interned. Merge validate_and_copy_tuple, the routine for cleaning up user input for code.__new__, into the internal intern_names. Note that this changes the exception type for non-string names in PyCode_NewWithPosOnlyArgs and such from SystemError to TypeError; IMO that doesn't need documenting. Rename intern_strings to intern_names to further distinguish it from intern_constants. Unlike constants, names are immortalized. Issue: gh-121954

Open Graph Description: Change _PyCode_New (intern_strings & intern_constants) to return new tuples rather than mutating their arguments. If possible, return the argument rather than create a copy. In order to make co...

X Description: Change _PyCode_New (intern_strings & intern_constants) to return new tuples rather than mutating their arguments. If possible, return the argument rather than create a copy. In order to mak...

Opengraph URL: https://github.com/python/cpython/pull/122180

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4bea3a65-44d0-5720-186a-cfca40f1accd
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id81DA:EAD6D:58AF6E:6F7527:6B0215B5
html-safe-noncecd429c911292be689353afecf0792ab956f2fc33e8616d94696944c4e51390d1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MURBOkVBRDZEOjU4QUY2RTo2Rjc1Mjc6NkIwMjE1QjUiLCJ2aXNpdG9yX2lkIjoiMjI3MTY5OTA5MDQ1MjY0OTM5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8534e336e07e5d836e307d4b9870e5ef7e3194865d0ce12c6b073e5ae31c0497
hovercard-subject-tagpull_request:1983508517
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/122180/files
twitter:imagehttps://avatars.githubusercontent.com/u/302922?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/302922?s=400&v=4
og:image:altChange _PyCode_New (intern_strings & intern_constants) to return new tuples rather than mutating their arguments. If possible, return the argument rather than create a copy. In order to make co...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
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

Links:

Skip to contenthttps://github.com/python/cpython/pull/122180/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F122180%2Ffiles
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%2Fpull%2F122180%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/122180/files
Reloadhttps://github.com/python/cpython/pull/122180/files
Reloadhttps://github.com/python/cpython/pull/122180/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
encukouhttps://github.com/encukou
python:mainhttps://github.com/python/cpython/tree/main
encukou:gh-121863https://github.com/encukou/cpython/tree/gh-121863
Conversation 17 https://github.com/python/cpython/pull/122180
Commits 20 https://github.com/python/cpython/pull/122180/commits
Checks 0 https://github.com/python/cpython/pull/122180/checks
Files changed https://github.com/python/cpython/pull/122180/files
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
gh-121954: Don't mutate tuples in _PyCode_New https://github.com/python/cpython/pull/122180/files#top
Show all changes 20 commits https://github.com/python/cpython/pull/122180/files
3c7050e Immortalize implicit arguments; use static sting for ".0" encukou Jul 17, 2024 https://github.com/python/cpython/pull/122180/commits/3c7050e9a72ff1848e3d1c5bbc8fe751cc91c206
2ebe868 Intern mangled identifiers after creation encukou Jul 17, 2024 https://github.com/python/cpython/pull/122180/commits/2ebe868e6c0dcd84769be4842ac3568c54a705e3
7ba01d5 Create new tuples with _PyCode_New encukou Jul 17, 2024 https://github.com/python/cpython/pull/122180/commits/7ba01d59a7f64450d950a210e62278d69497595d
ff7f4e6 Intern strings in _PyCode_ConstantKey encukou Jul 23, 2024 https://github.com/python/cpython/pull/122180/commits/ff7f4e6695153c81b9955761832244ed18229c43
c2db0f0 Merge validate_and_copy_tuple into intern_names encukou Jul 23, 2024 https://github.com/python/cpython/pull/122180/commits/c2db0f0aa83bd3016381f335ce362106538ce070
259d2ca Remove test that asserted a constant is *not* interned encukou Jul 23, 2024 https://github.com/python/cpython/pull/122180/commits/259d2caab39c1c4e19c1cf1ea8263af298a8cccc
891304d Fix ref handling in error case encukou Jul 23, 2024 https://github.com/python/cpython/pull/122180/commits/891304ddab50e6b44509fc2a2bea1889cad96bae
1e655b2 Skip interning in _Py_Mangle (_PyCode_ConstantKey is enough) encukou Jul 23, 2024 https://github.com/python/cpython/pull/122180/commits/1e655b2dbed03989ea931807cf2960b13354abbd
a75078f Add blurb encukou Jul 23, 2024 https://github.com/python/cpython/pull/122180/commits/a75078fc845313c331a278f5e72ba58971614db1
2557b5b Immortalize localsplusnames encukou Jul 24, 2024 https://github.com/python/cpython/pull/122180/commits/2557b5b3550b74e161b0a37eb543b78bcd6dbc46
9bca4c6 Free-threading: Re-add lock for intern_constants encukou Jul 24, 2024 https://github.com/python/cpython/pull/122180/commits/9bca4c69d133ada11fa6c963fa3f5a8dc5d1e04e
3939ac5 Merge in the main branch encukou Aug 3, 2024 https://github.com/python/cpython/pull/122180/commits/3939ac582779d614dbee980fcde17c9051c309da
25dbda6 Intern tuples in free-threaded build encukou Aug 3, 2024 https://github.com/python/cpython/pull/122180/commits/25dbda6f388037c833f99dfaa98c02b011000732
b33c1eb Intern the outer tuples like any other object encukou Aug 3, 2024 https://github.com/python/cpython/pull/122180/commits/b33c1eb3c687b450eb119776a7892a48d27e292a
cd6086f Regenerate test_frozenmain.h encukou Aug 3, 2024 https://github.com/python/cpython/pull/122180/commits/cd6086f85fc0df9fadf8a0d99ac9a753280ef1f8
ecd7ae7 Adjust comment for _PyCode_Fini encukou Aug 12, 2024 https://github.com/python/cpython/pull/122180/commits/ecd7ae75a5f545033725eb118fa14361a31baa9c
34f5119 Merge in the main branch encukou Aug 12, 2024 https://github.com/python/cpython/pull/122180/commits/34f5119ffc257eaa2a75ecc76e9ad4b2700553b2
aa1a5ca Add tests for converting to strict unicode encukou Aug 12, 2024 https://github.com/python/cpython/pull/122180/commits/aa1a5ca0dfa5c7f6ec393286e2f95c5213de2530
e705379 Unlock mutex in error path encukou Aug 12, 2024 https://github.com/python/cpython/pull/122180/commits/e705379ae5413a46c74c305a28807173b6188a0e
ed6115f Add braces to if bodies encukou Aug 12, 2024 https://github.com/python/cpython/pull/122180/commits/ed6115fad5f5cf9149ade8edd86d67862492949b
Clear filters https://github.com/python/cpython/pull/122180/files
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
pycore_global_objects_fini_generated.h https://github.com/python/cpython/pull/122180/files#diff-31f682b2a04cda997f449a9816ee5fae305e3bfa7357afcb794615921c6a88d2
pycore_global_strings.h https://github.com/python/cpython/pull/122180/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
pycore_runtime_init_generated.h https://github.com/python/cpython/pull/122180/files#diff-69a1fc720f0b1e9005cf7717dd81c823399da81dd2f6480664b51238c1ef93f0
pycore_unicodeobject_generated.h https://github.com/python/cpython/pull/122180/files#diff-510f6084b63d39305481b719ae0a29475ba759e259a8e4cee4f07c451ffbb2d6
test_code.py https://github.com/python/cpython/pull/122180/files#diff-08d8a239ab9b84cf01875e28a6dae873628b56bfe94d30c3336c4a607d8036e5
2024-07-23-16-20-02.gh-issue-121954.ydF8sg.rst https://github.com/python/cpython/pull/122180/files#diff-6005c4ba3431d8f15d7a992ff722c956eeb4bdda3b56ce7b7de39a003ba095ca
codeobject.c https://github.com/python/cpython/pull/122180/files#diff-6f869eb8beb7cbe4bc6817584b99ad567f88962fa67f7beca25d009dc401234d
test_frozenmain.h https://github.com/python/cpython/pull/122180/files#diff-dcbbf153f77c69fb3a08746516bb9baaf46b9465c941221d1d495123e92cc862
pylifecycle.c https://github.com/python/cpython/pull/122180/files#diff-69223f5bb01f359a23246afbbf75b45c622e719424418d658674fbb6c2b36fad
symtable.c https://github.com/python/cpython/pull/122180/files#diff-1029343b7709f438c869082355577469b5aa784b454afa461ca2844ce9910ea6
Include/internal/pycore_global_objects_fini_generated.hhttps://github.com/python/cpython/pull/122180/files#diff-31f682b2a04cda997f449a9816ee5fae305e3bfa7357afcb794615921c6a88d2
View file https://github.com/python/cpython/blob/ed6115fad5f5cf9149ade8edd86d67862492949b/Include/internal/pycore_global_objects_fini_generated.h
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
Include/internal/pycore_global_strings.hhttps://github.com/python/cpython/pull/122180/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
View file https://github.com/python/cpython/blob/ed6115fad5f5cf9149ade8edd86d67862492949b/Include/internal/pycore_global_strings.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/122180/{{ revealButtonHref }}
https://github.com/python/cpython/pull/122180/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
https://github.com/python/cpython/pull/122180/files#diff-7656e411eccd63ff8aab3e11de3f45035665f6b639206d3f440727dfb5e0ebcf
Include/internal/pycore_runtime_init_generated.hhttps://github.com/python/cpython/pull/122180/files#diff-69a1fc720f0b1e9005cf7717dd81c823399da81dd2f6480664b51238c1ef93f0
View file https://github.com/python/cpython/blob/ed6115fad5f5cf9149ade8edd86d67862492949b/Include/internal/pycore_runtime_init_generated.h
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
Include/internal/pycore_unicodeobject_generated.hhttps://github.com/python/cpython/pull/122180/files#diff-510f6084b63d39305481b719ae0a29475ba759e259a8e4cee4f07c451ffbb2d6
View file https://github.com/python/cpython/blob/ed6115fad5f5cf9149ade8edd86d67862492949b/Include/internal/pycore_unicodeobject_generated.h
Open in desktop https://desktop.github.com
how customized files appear on GitHubhttps://docs.github.com/github/administering-a-repository/customizing-how-changed-files-appear-on-github
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
Lib/test/test_code.pyhttps://github.com/python/cpython/pull/122180/files#diff-08d8a239ab9b84cf01875e28a6dae873628b56bfe94d30c3336c4a607d8036e5
View file https://github.com/python/cpython/blob/ed6115fad5f5cf9149ade8edd86d67862492949b/Lib/test/test_code.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/122180/{{ revealButtonHref }}
https://github.com/python/cpython/pull/122180/files#diff-08d8a239ab9b84cf01875e28a6dae873628b56bfe94d30c3336c4a607d8036e5
https://github.com/python/cpython/pull/122180/files#diff-08d8a239ab9b84cf01875e28a6dae873628b56bfe94d30c3336c4a607d8036e5
https://github.com/python/cpython/pull/122180/files#diff-08d8a239ab9b84cf01875e28a6dae873628b56bfe94d30c3336c4a607d8036e5
https://github.com/python/cpython/pull/122180/files#diff-08d8a239ab9b84cf01875e28a6dae873628b56bfe94d30c3336c4a607d8036e5
Misc/NEWS.d/next/Core_and_Builtins/2024-07-23-16-20-02.gh-issue-121954.ydF8sg.rsthttps://github.com/python/cpython/pull/122180/files#diff-6005c4ba3431d8f15d7a992ff722c956eeb4bdda3b56ce7b7de39a003ba095ca
View file https://github.com/python/cpython/blob/ed6115fad5f5cf9149ade8edd86d67862492949b/Misc/NEWS.d/next/Core_and_Builtins/2024-07-23-16-20-02.gh-issue-121954.ydF8sg.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/122180/{{ revealButtonHref }}
Please reload this pagehttps://github.com/python/cpython/pull/122180/files
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.