René's URL Explorer Experiment


Title: gh-142183: Change data stack to use a resizable array by dpdani · Pull Request #148681 · python/cpython · GitHub

Open Graph Title: gh-142183: Change data stack to use a resizable array by dpdani · Pull Request #148681 · python/cpython

X Title: gh-142183: Change data stack to use a resizable array by dpdani · Pull Request #148681 · python/cpython

Description: This PR changes the implementation of the Python stack to use a resizable array. This avoids the problem of calls that frequently cause the datastack_top (now called stack_top) pointer to switch between allocations. After resizing, previous array allocations are not immediately freed because that would cause issues for various bits around the VM still pointing into them, and are instead freed along with the tstate. During resizing, the previous contents of the stack are not copied into the new allocations, and instead the memory of the previous allocation is still used. Subsequently, popping and pushing frames, the new frames will always be residing on the new stack chunk allocation. Overall it results in a ±1% performance change (within the noise range), but it avoids degenerate cases for any number of frames. I am also told it would allow further optimizations in the JIT. Issue: gh-142183

Open Graph Description: This PR changes the implementation of the Python stack to use a resizable array. This avoids the problem of calls that frequently cause the datastack_top (now called stack_top) pointer to switch be...

X Description: This PR changes the implementation of the Python stack to use a resizable array. This avoids the problem of calls that frequently cause the datastack_top (now called stack_top) pointer to switch be...

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

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:9fc02ec0-6136-f3a5-5310-f24cf863f220
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB948:B1B84:383B761:4779159:6B022CE3
html-safe-noncea89438ed4367c742e19cb420b6997c517a74999c8f3bad27542c19997bdbe45b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTQ4OkIxQjg0OjM4M0I3NjE6NDc3OTE1OTo2QjAyMkNFMyIsInZpc2l0b3JfaWQiOiI1MzM1ODg2MTE0MTM1ODc4ODgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb823ff98fbf691b3a5677f93a56575e91e6bd60415aaf96d60d2ea3c40c572d0
hovercard-subject-tagpull_request:3545201851
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/148681/files
twitter:imagehttps://avatars.githubusercontent.com/u/8658291?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/8658291?s=400&v=4
og:image:altThis PR changes the implementation of the Python stack to use a resizable array. This avoids the problem of calls that frequently cause the datastack_top (now called stack_top) pointer to switch be...
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-targetcanary-1
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/148681/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F148681%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%2F148681%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/148681/files
Reloadhttps://github.com/python/cpython/pull/148681/files
Reloadhttps://github.com/python/cpython/pull/148681/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
dpdanihttps://github.com/dpdani
python:mainhttps://github.com/python/cpython/tree/main
dpdani:gh-142183-stack-resizable-arrayhttps://github.com/dpdani/cpython/tree/gh-142183-stack-resizable-array
Conversation 28 https://github.com/python/cpython/pull/148681
Commits 16 https://github.com/python/cpython/pull/148681/commits
Checks 56 https://github.com/python/cpython/pull/148681/checks
Files changed 20 https://github.com/python/cpython/pull/148681/files
gh-142183: Change data stack to use a resizable array https://github.com/python/cpython/pull/148681/files#top
Show all changes 16 commits https://github.com/python/cpython/pull/148681/files
cfaca85 gh-142183: Change data stack to use a resizable array dpdani Apr 17, 2026 https://github.com/python/cpython/pull/148681/commits/cfaca8519151fd3f1398da0a9ced63ee3aa633f8
bb08739 📜🤖 Added by blurb_it. blurb-it[bot] Apr 17, 2026 https://github.com/python/cpython/pull/148681/commits/bb087392fc8e1a8902494ae28aacb15ddbc81070
99bb502 skip tests failing on emscripten dpdani Apr 20, 2026 https://github.com/python/cpython/pull/148681/commits/99bb502d1417111c92b3dc105f1141d1fab71545
daa182a Merge branch 'main' into gh-142183-stack-resizable-array dpdani Apr 27, 2026 https://github.com/python/cpython/pull/148681/commits/daa182abb858909e41b9bd4c8d6fe6187090e9d0
99e9e44 Fix regression in profiler module pablogsal Apr 28, 2026 https://github.com/python/cpython/pull/148681/commits/99e9e44e49cea6f1e1db745d1b29aeb0964d4fe4
bab3d69 improve docs dpdani May 8, 2026 https://github.com/python/cpython/pull/148681/commits/bab3d69d5baaf821a21a2214b1945506dbf601a0
772a834 regen-all dpdani May 8, 2026 https://github.com/python/cpython/pull/148681/commits/772a834533b178e3379a12cffe3fec4a0ff61ab9
67e89ce Merge branch 'main' into gh-142183-stack-resizable-array dpdani May 8, 2026 https://github.com/python/cpython/pull/148681/commits/67e89ce9a57f74d1d724fb3e74dab2f92448c985
970282d Merge branch 'main' into gh-142183-stack-resizable-array dpdani May 8, 2026 https://github.com/python/cpython/pull/148681/commits/970282d2717087400de0cff8ef7960e5e6206eb1
5f98e7e regen-all dpdani May 8, 2026 https://github.com/python/cpython/pull/148681/commits/5f98e7ef2f70dd9e4392293cbc0221eb30f1cb36
73e1457 regen-all dpdani May 8, 2026 https://github.com/python/cpython/pull/148681/commits/73e14570874a68322710a24636352a015e063197
4d140ca free up chunks when they become unused dpdani May 12, 2026 https://github.com/python/cpython/pull/148681/commits/4d140caaf1c39f94563894445040d2a337c9f57e
847ddad Merge branch 'main' into gh-142183-stack-resizable-array dpdani May 12, 2026 https://github.com/python/cpython/pull/148681/commits/847ddad545c6c407e86dea42721cc30b67acde5a
a6411de make regen-all dpdani May 12, 2026 https://github.com/python/cpython/pull/148681/commits/a6411deac3a9be5eb370315893a38e608dcc6e61
3ff3d94 Merge branch 'main' into gh-142183-stack-resizable-array dpdani Jun 2, 2026 https://github.com/python/cpython/pull/148681/commits/3ff3d94d368798be96e7258db84cf9b9a967bea8
00342e0 make regen-all dpdani Jun 2, 2026 https://github.com/python/cpython/pull/148681/commits/00342e0b22cc743243d6f91ba8574d1169b9c3b6
Clear filters https://github.com/python/cpython/pull/148681/files
Please reload this pagehttps://github.com/python/cpython/pull/148681/files
Please reload this pagehttps://github.com/python/cpython/pull/148681/files
pystate.h https://github.com/python/cpython/pull/148681/files#diff-fefbbf791abe2a1b6d9cab39778d388ebb9135eeefbd734e463aac75d1979e7f
pycore_debug_offsets.h https://github.com/python/cpython/pull/148681/files#diff-d8033f43b559c40be94454492b311002424abce21cfe647fd01363e7de330435
pycore_interpframe.h https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
pycore_runtime_init.h https://github.com/python/cpython/pull/148681/files#diff-84d4b72a69538f6e60865f5c0301f102c0dca577e47759ac07d7a9a034ee75a2
frames.md https://github.com/python/cpython/pull/148681/files#diff-478c9c5c910a9c5e5af13653fccd6ce6a76555d30ff636a8ffd8418922721f18
stack-resize-pop-push.dot https://github.com/python/cpython/pull/148681/files#diff-ffdc9fa01dce52d54216b6a6bed83759e6e8eb637c1d23e9c153ff294822604a
stack-resize-pop-push.png https://github.com/python/cpython/pull/148681/files#diff-3ae78c4a42b4e7117c99ee2810802b21a19cdc75b5f506ffa3acfca5d5707f3f
stack-resize.dot https://github.com/python/cpython/pull/148681/files#diff-cf9825bda749e78646e7c91cc740f0165b88d070ffcd9d457b12a198bad4f030
stack-resize.png https://github.com/python/cpython/pull/148681/files#diff-9d9a480345fb8b7647cc201b479ffd07eccaeadb1bd799efc599cc8534dacf4f
test_external_inspection.py https://github.com/python/cpython/pull/148681/files#diff-e23d1425a6f43944cb282709edbeacfa2398f4cd4c109e59dd49366dac46f2d7
test_isinstance.py https://github.com/python/cpython/pull/148681/files#diff-221b84ceb8809408af7e1851deabdf6ccd4e309b15e1cc4fc429ff4692d56d59
test_unix_console.py https://github.com/python/cpython/pull/148681/files#diff-bd56b95d174a8939e71984be3453d3a41315d3fdab37649a87f5c79703f9d304
2026-04-17-12-27-33.gh-issue-142183.jKFUky.rst https://github.com/python/cpython/pull/148681/files#diff-83919c7cb7645bdbc09235df4325cca8d0169a59821ac1dc4fd1bd1fde17a8c4
_remote_debugging.h https://github.com/python/cpython/pull/148681/files#diff-a6ce0bef7825b17047f05fdec7aa610bc1d2d2b368e72b6871a79c3b1d2dfaf9
module.c.h https://github.com/python/cpython/pull/148681/files#diff-2d77f9076431c6bf915dddc94789761eb0f429fc4225274c067b40b099199ee2
debug_offsets_validation.h https://github.com/python/cpython/pull/148681/files#diff-b5ca165ebc409e0854c3a65380333e6251c3f896765bea8c09d662293532094d
frames.c https://github.com/python/cpython/pull/148681/files#diff-7d46b926220bc5035fbce1ec940bb27482bcd7683fdcbc1f60b1fd2bb9bf6f41
module.c https://github.com/python/cpython/pull/148681/files#diff-9676fd8cee6e0d841f42f405a8e33a434fbebbc861207051571c97cef17c4108
ceval.c https://github.com/python/cpython/pull/148681/files#diff-c22186367cbe20233e843261998dc027ae5f1f8c0d2e778abfa454ae74cc59de
pystate.c https://github.com/python/cpython/pull/148681/files#diff-7ac11e526f79b42d6ea9d3592cb99da46775640c69fa5510f4a6de87cced7141
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L319
Include/cpython/pystate.hhttps://github.com/python/cpython/pull/148681/files#diff-fefbbf791abe2a1b6d9cab39778d388ebb9135eeefbd734e463aac75d1979e7f
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/Include/cpython/pystate.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/148681/{{ revealButtonHref }}
https://github.com/python/cpython/pull/148681/files#diff-fefbbf791abe2a1b6d9cab39778d388ebb9135eeefbd734e463aac75d1979e7f
https://github.com/python/cpython/pull/148681/files#diff-fefbbf791abe2a1b6d9cab39778d388ebb9135eeefbd734e463aac75d1979e7f
https://github.com/python/cpython/pull/148681/files#diff-fefbbf791abe2a1b6d9cab39778d388ebb9135eeefbd734e463aac75d1979e7f
https://github.com/python/cpython/pull/148681/files#diff-fefbbf791abe2a1b6d9cab39778d388ebb9135eeefbd734e463aac75d1979e7f
Include/internal/pycore_debug_offsets.hhttps://github.com/python/cpython/pull/148681/files#diff-d8033f43b559c40be94454492b311002424abce21cfe647fd01363e7de330435
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/Include/internal/pycore_debug_offsets.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/148681/{{ revealButtonHref }}
https://github.com/python/cpython/pull/148681/files#diff-d8033f43b559c40be94454492b311002424abce21cfe647fd01363e7de330435
https://github.com/python/cpython/pull/148681/files#diff-d8033f43b559c40be94454492b311002424abce21cfe647fd01363e7de330435
https://github.com/python/cpython/pull/148681/files#diff-d8033f43b559c40be94454492b311002424abce21cfe647fd01363e7de330435
https://github.com/python/cpython/pull/148681/files#diff-d8033f43b559c40be94454492b311002424abce21cfe647fd01363e7de330435
Include/internal/pycore_interpframe.hhttps://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/Include/internal/pycore_interpframe.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/148681/{{ revealButtonHref }}
https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
P403n1x87https://github.com/P403n1x87
Apr 29, 2026https://github.com/python/cpython/pull/148681/files#r3160429345
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/148681/files
dpdanihttps://github.com/dpdani
Apr 29, 2026https://github.com/python/cpython/pull/148681/files#r3161496311
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdfhttps://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
Please reload this pagehttps://github.com/python/cpython/pull/148681/files
https://github.com/python/cpython/pull/148681/files#diff-a6652fbbdfbbc0185be9175f6e7219e704d7a86a874020f3ee99f70955892cff
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L320
Include/internal/pycore_runtime_init.hhttps://github.com/python/cpython/pull/148681/files#diff-84d4b72a69538f6e60865f5c0301f102c0dca577e47759ac07d7a9a034ee75a2
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/Include/internal/pycore_runtime_init.h
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/148681/{{ revealButtonHref }}
https://github.com/python/cpython/pull/148681/files#diff-84d4b72a69538f6e60865f5c0301f102c0dca577e47759ac07d7a9a034ee75a2
https://github.com/python/cpython/pull/148681/files#diff-84d4b72a69538f6e60865f5c0301f102c0dca577e47759ac07d7a9a034ee75a2
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L100
InternalDocs/frames.mdhttps://github.com/python/cpython/pull/148681/files#diff-478c9c5c910a9c5e5af13653fccd6ce6a76555d30ff636a8ffd8418922721f18
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/InternalDocs/frames.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/148681/{{ revealButtonHref }}
https://github.com/python/cpython/pull/148681/files#diff-478c9c5c910a9c5e5af13653fccd6ce6a76555d30ff636a8ffd8418922721f18
https://github.com/python/cpython/pull/148681/files#diff-478c9c5c910a9c5e5af13653fccd6ce6a76555d30ff636a8ffd8418922721f18
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L100
InternalDocs/images/stack-resize-pop-push.dothttps://github.com/python/cpython/pull/148681/files#diff-ffdc9fa01dce52d54216b6a6bed83759e6e8eb637c1d23e9c153ff294822604a
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/InternalDocs/images/stack-resize-pop-push.dot
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/148681/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L100
InternalDocs/images/stack-resize-pop-push.pnghttps://github.com/python/cpython/pull/148681/files#diff-3ae78c4a42b4e7117c99ee2810802b21a19cdc75b5f506ffa3acfca5d5707f3f
View file https://github.com/python/cpython/blob/00342e0b22cc743243d6f91ba8574d1169b9c3b6/InternalDocs/images/stack-resize-pop-push.png
Open in desktop https://desktop.github.com
Reload?https://github.com/python/cpython/pull/148681/files
Please reload this pagehttps://github.com/python/cpython/pull/148681/files
Please reload this pagehttps://github.com/python/cpython/pull/148681/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.