René's URL Explorer Experiment


Title: gh-117045: Add code object to function version cache by gvanrossum · Pull Request #117028 · python/cpython · GitHub

Open Graph Title: gh-117045: Add code object to function version cache by gvanrossum · Pull Request #117028 · python/cpython

X Title: gh-117045: Add code object to function version cache by gvanrossum · Pull Request #117028 · python/cpython

Description: What? Changes to the function version cache: In addition to the function object, also store the code object, and allow the latter to be retrieved even if the function has been evicted. Stop assigning new function versions after a critical attribute (e.g. __code__) has been modified; the version is permanently reset to zero in this case. Changes to __annotations__ are no longer considered critical. (This fixes gh-109998.) Changes to the Tier 2 optimization machinery: If we cannot map a function version to a function, but it is still mapped to a code object, we continue projecting the trace. The operand of the _PUSH_FRAME and _POP_FRAME opcodes can be either NULL, a function object, or a code object with the lowest bit set. Why? This allows us to trace through code that calls an ephemeral function, i.e., a function that may not be alive when we are constructing the executor, e.g. a generator expression or certain nested functions. We will lose globals removal inside such functions, but we can still do other peephole operations (and even possibly call inlining, if we decide to do it), which only need the code object. As before, if we cannot retrieve the code object from the cache, we stop projecting. For more details see the issue. Issue: gh-117045

Open Graph Description: What? Changes to the function version cache: In addition to the function object, also store the code object, and allow the latter to be retrieved even if the function has been evicted. Stop assign...

X Description: What? Changes to the function version cache: In addition to the function object, also store the code object, and allow the latter to be retrieved even if the function has been evicted. Stop assign...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e4f55669-ff24-9867-3900-5c419f4778fc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA7DE:28F8C1:237D2E1:33846F5:6A565E8F
html-safe-nonce2115c9bb7ebfa4f18bd982b726595db8d20d4fa950089694dee0597c912532ca
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBN0RFOjI4RjhDMToyMzdEMkUxOjMzODQ2RjU6NkE1NjVFOEYiLCJ2aXNpdG9yX2lkIjoiODk1NDk4MzE4NzMyODk0OTkwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace695bb3e043b28c779ab3e9715d5b5434e339eef131fd376d97d34ed7824410f
hovercard-subject-tagpull_request:1780589462
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/117028/files
twitter:imagehttps://avatars.githubusercontent.com/u/2894642?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/2894642?s=400&v=4
og:image:altWhat? Changes to the function version cache: In addition to the function object, also store the code object, and allow the latter to be retrieved even if the function has been evicted. Stop assign...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None6a3afe34dff341ad10912db44becf282289d7f2af20576241738530fbb28de01
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
releaseb71002134df95575e9f6c2945a64d454b0be181e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/117028/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F117028%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F117028%2Ffiles
Sign up https://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/117028/files
Reloadhttps://github.com/python/cpython/pull/117028/files
Reloadhttps://github.com/python/cpython/pull/117028/files
Please reload this pagehttps://github.com/python/cpython/pull/117028/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/117028/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
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
gvanrossumhttps://github.com/gvanrossum
python:mainhttps://github.com/python/cpython/tree/main
gvanrossum:func-version-cachehttps://github.com/gvanrossum/cpython/tree/func-version-cache
Conversation 13 https://github.com/python/cpython/pull/117028
Commits 14 https://github.com/python/cpython/pull/117028/commits
Checks 0 https://github.com/python/cpython/pull/117028/checks
Files changed https://github.com/python/cpython/pull/117028/files
Please reload this pagehttps://github.com/python/cpython/pull/117028/files
gh-117045: Add code object to function version cache https://github.com/python/cpython/pull/117028/files#top
Show all changes 14 commits https://github.com/python/cpython/pull/117028/files
21dc79c Leave func_version zero after critical mutations gvanrossum Mar 18, 2024 https://github.com/python/cpython/pull/117028/commits/21dc79ce1011d94c0aa7fc1f6435490e9fc96b22
51bc626 Change the function version cache to contain a (func, code) pair gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/51bc6260f9bc503ca8cd04f955dbf3cd2160eefe
0d5f849 Use _PyFrame_GetCode where needed; tweak a debug print gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/0d5f84945ce64a7a77ffda055e084967ff043dcc
b998bf2 Clarify type of f_executable gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/b998bf2b0a54dcbcb7aba828a060609a1af6b07e
fdbfe07 Change the operand for _PUSH_FRAME gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/fdbfe070ba973e9d6e9deea32daf45104dce01ae
fe149b2 Rewrite explanatory comment gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/fe149b23ae053f2fed9f45c526ea5b746ec40fe6
0d0551e Add code to the trace stack in translate_bytecode_to_trace() gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/0d0551ebc1f322cbecfc1b1855c5638a98da05c8
b999d3e Set operand for _PUSH/_POP_FRAME more consistently gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/b999d3e7f07161250e4ed67554911877eb540ef8
b8141cd Remove bogus assert gvanrossum Mar 19, 2024 https://github.com/python/cpython/pull/117028/commits/b8141cdef31fff03e4df27d4acf6d0a9f2d6542b
0fd96be Document and enforce invariants gvanrossum Mar 20, 2024 https://github.com/python/cpython/pull/117028/commits/0fd96be84aa28ad987f76686139037a6352b06c1
6748a56 Enforce invariant differently gvanrossum Mar 20, 2024 https://github.com/python/cpython/pull/117028/commits/6748a56bd8059dd520d12bd4c8f7ce28ddf3536f
fac617c Revert "Remove bogus assert" (it's not my job to fix this) gvanrossum Mar 20, 2024 https://github.com/python/cpython/pull/117028/commits/fac617c5842ce3b5f710318ce2f337cc57815d08
37fab3c Address code review gvanrossum Mar 20, 2024 https://github.com/python/cpython/pull/117028/commits/37fab3cc323780dc5ac3cd9916eae89a526608ca
f3de0ef Merge remote-tracking branch 'origin/main' into func-version-cache gvanrossum Mar 20, 2024 https://github.com/python/cpython/pull/117028/commits/f3de0ef69d99784cdeb602dab27c61a2b2a5a2d5
Clear filters https://github.com/python/cpython/pull/117028/files
Please reload this pagehttps://github.com/python/cpython/pull/117028/files
Please reload this pagehttps://github.com/python/cpython/pull/117028/files
pycore_frame.h https://github.com/python/cpython/pull/117028/files#diff-dc43b169f3202922a7787b97210ce299172f0cf03bd88529d473128f32e49fe4
pycore_function.h https://github.com/python/cpython/pull/117028/files#diff-c4efb36e1ad7be7992f0652a436b45ba6dbd05e88954c629f920008d2edc7566
codeobject.c https://github.com/python/cpython/pull/117028/files#diff-6f869eb8beb7cbe4bc6817584b99ad567f88962fa67f7beca25d009dc401234d
funcobject.c https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
optimizer.c https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
optimizer_analysis.c https://github.com/python/cpython/pull/117028/files#diff-eac5ab7e741b8b825a24d31a5bf844e86086431fb698cfcabe1277b68c375ca2
optimizer_bytecodes.c https://github.com/python/cpython/pull/117028/files#diff-e5bd2b14b0b10f0f47786e26306d689ed1361c3dc3b11dcc3ea52b8a2422ff64
optimizer_cases.c.h https://github.com/python/cpython/pull/117028/files#diff-ed4567b3e67709ec57bf4df91ef058cfcbe00d7da11cd2a75e38241fa1ca99d2
Include/internal/pycore_frame.hhttps://github.com/python/cpython/pull/117028/files#diff-dc43b169f3202922a7787b97210ce299172f0cf03bd88529d473128f32e49fe4
View file https://github.com/gvanrossum/cpython/blob/f3de0ef69d99784cdeb602dab27c61a2b2a5a2d5/Include/internal/pycore_frame.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/117028/{{ revealButtonHref }}
https://github.com/python/cpython/pull/117028/files#diff-dc43b169f3202922a7787b97210ce299172f0cf03bd88529d473128f32e49fe4
https://github.com/python/cpython/pull/117028/files#diff-dc43b169f3202922a7787b97210ce299172f0cf03bd88529d473128f32e49fe4
Include/internal/pycore_function.hhttps://github.com/python/cpython/pull/117028/files#diff-c4efb36e1ad7be7992f0652a436b45ba6dbd05e88954c629f920008d2edc7566
View file https://github.com/gvanrossum/cpython/blob/f3de0ef69d99784cdeb602dab27c61a2b2a5a2d5/Include/internal/pycore_function.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/117028/{{ revealButtonHref }}
https://github.com/python/cpython/pull/117028/files#diff-c4efb36e1ad7be7992f0652a436b45ba6dbd05e88954c629f920008d2edc7566
https://github.com/python/cpython/pull/117028/files#diff-c4efb36e1ad7be7992f0652a436b45ba6dbd05e88954c629f920008d2edc7566
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L214
Objects/codeobject.chttps://github.com/python/cpython/pull/117028/files#diff-6f869eb8beb7cbe4bc6817584b99ad567f88962fa67f7beca25d009dc401234d
View file https://github.com/gvanrossum/cpython/blob/f3de0ef69d99784cdeb602dab27c61a2b2a5a2d5/Objects/codeobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/117028/{{ revealButtonHref }}
https://github.com/python/cpython/pull/117028/files#diff-6f869eb8beb7cbe4bc6817584b99ad567f88962fa67f7beca25d009dc401234d
https://github.com/python/cpython/pull/117028/files#diff-6f869eb8beb7cbe4bc6817584b99ad567f88962fa67f7beca25d009dc401234d
Objects/funcobject.chttps://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
View file https://github.com/gvanrossum/cpython/blob/f3de0ef69d99784cdeb602dab27c61a2b2a5a2d5/Objects/funcobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/117028/{{ revealButtonHref }}
https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
Please reload this pagehttps://github.com/python/cpython/pull/117028/files
https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
https://github.com/python/cpython/pull/117028/files#diff-57bc77178b3d6f1010dd924722c87522f224d93bc341f0e46c0945094124d8f2
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L305
Python/optimizer.chttps://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
View file https://github.com/gvanrossum/cpython/blob/f3de0ef69d99784cdeb602dab27c61a2b2a5a2d5/Python/optimizer.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/117028/{{ revealButtonHref }}
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
https://github.com/python/cpython/pull/117028/files#diff-de09f74c4306be5ef0284d665091976873569094d645a35b48467ea2a11d67f7
Please reload this pagehttps://github.com/python/cpython/pull/117028/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.