René's URL Explorer Experiment


Title: gh-158592: Reallocate the list's array when deleting by index by x42005e1f · Pull Request #158602 · python/cpython · GitHub

Open Graph Title: gh-158592: Reallocate the list's array when deleting by index by x42005e1f · Pull Request #158602 · python/cpython

X Title: gh-158592: Reallocate the list's array when deleting by index by x42005e1f · Pull Request #158602 · python/cpython

Description: Fixes the linked issue with a simple one-line change, copy-pasted from list_pop_impl(). Ideally, the v == NULL branch of the list_ass_item_lock_held() function should be code-synchronized with the one mentioned, since the implementation of list_pop_impl() appears to be more efficient, but that is beyond the scope of this PR. Performance comparison: Details $ ./python -m pyperf timeit -s 'obj = []' 'obj.append(None); del obj[-1]' --duplicate 1000 ..................... Mean +- std dev: 19.3 ns +- 0.0 ns $ ./python -m pyperf timeit -s 'obj = [None]' 'obj.append(None); del obj[-1]' --duplicate 1000 ..................... Mean +- std dev: 19.3 ns +- 0.1 ns $ ./python -m pyperf timeit -s 'obj = []' 'obj.append(None); del obj[-1]' --duplicate 1000 ..................... Mean +- std dev: 50.3 ns +- 0.3 ns $ ./python -m pyperf timeit -s 'obj = [None]' 'obj.append(None); del obj[-1]' --duplicate 1000 ..................... Mean +- std dev: 27.1 ns +- 0.1 ns Benchmark before after 0-1 items 19.3 ns 50.3 ns: 2.61x slower 1-2 items 19.3 ns 27.1 ns: 1.40x slower The first case always reallocates the array, while the second case never reallocates the array (see #158602 (comment)). The results appear to be a performance regression, but it is important to understand what this change actually does. Namely, it simply restores the missed reallocation that other methods already perform (del list[slice], list.pop(), list.remove(), etc.)! If you are concerned about this, you should change the list_resize() implementation rather than making the collection non-shrinkable in terms of capacity. I decided not to add a regression test because it would depend on the exact behavior of the list_resize() function (specifically, when it decides to change the capacity), which would require updating the test whenever its condition changed. Issue: gh-158592

Open Graph Description: Fixes the linked issue with a simple one-line change, copy-pasted from list_pop_impl(). Ideally, the v == NULL branch of the list_ass_item_lock_held() function should be code-synchronized with the ...

X Description: Fixes the linked issue with a simple one-line change, copy-pasted from list_pop_impl(). Ideally, the v == NULL branch of the list_ass_item_lock_held() function should be code-synchronized with the ...

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

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:2d49e1d7-4455-75f7-3fb1-4e0878e5284b
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB1B8:2E7DFB:3055C4:3F9C75:6B02345B
html-safe-nonce0f0ce5559109128c0198c5824046e7721e6ddb0384f8bdc9f616bbf0b40d543f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUI4OjJFN0RGQjozMDU1QzQ6M0Y5Qzc1OjZCMDIzNDVCIiwidmlzaXRvcl9pZCI6IjE0NDA0MzY4MzkyMTg1NTgwNDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4ad1abbd45a85c6453c112cbb5baee596573a2aa7e8a002d9c0fc922331b19ef
hovercard-subject-tagpull_request:4717436144
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/158602/files
twitter:imagehttps://avatars.githubusercontent.com/u/141886287?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/141886287?s=400&v=4
og:image:altFixes the linked issue with a simple one-line change, copy-pasted from list_pop_impl(). Ideally, the v == NULL branch of the list_ass_item_lock_held() function should be code-synchronized with the ...
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/158602/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F158602%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%2F158602%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/158602/files
Reloadhttps://github.com/python/cpython/pull/158602/files
Reloadhttps://github.com/python/cpython/pull/158602/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
corona10https://github.com/corona10
python:mainhttps://github.com/python/cpython/tree/main
x42005e1f:gh-158592https://github.com/x42005e1f/cpython/tree/gh-158592
Conversation 33 https://github.com/python/cpython/pull/158602
Commits 6 https://github.com/python/cpython/pull/158602/commits
Checks 53 https://github.com/python/cpython/pull/158602/checks
Files changed 2 https://github.com/python/cpython/pull/158602/files
gh-158592: Reallocate the list's array when deleting by index https://github.com/python/cpython/pull/158602/files#top
Show all changes 6 commits https://github.com/python/cpython/pull/158602/files
e7e439b gh-158592: Reallocate the list's array when deleting by index x42005e1f Oct 2, 2026 https://github.com/python/cpython/pull/158602/commits/e7e439bd1dbc9fa5fea983358f7581c588045b73
093ab9b Add a NEWS entry x42005e1f Oct 2, 2026 https://github.com/python/cpython/pull/158602/commits/093ab9bacf1353b79d7d8a00e6850aaccbb3a2b5
6f68a64 Apply the suggested change x42005e1f Oct 3, 2026 https://github.com/python/cpython/pull/158602/commits/6f68a64cd7d055a84f407c643bd2c9f74fdb79bc
fa0e380 Apply the suggested change (again) x42005e1f Oct 5, 2026 https://github.com/python/cpython/pull/158602/commits/fa0e380acc6fb3e5f5249194359f728d9275719d
9c8223e Merge branch 'main' into gh-158592 corona10 Oct 6, 2026 https://github.com/python/cpython/pull/158602/commits/9c8223e1c2a741c5dfad1f3a318f8afab8073765
ad8cdb7 Merge branch 'main' into gh-158592 corona10 Oct 7, 2026 https://github.com/python/cpython/pull/158602/commits/ad8cdb7c184126f43c811a4a94f667e2ead28858
Clear filters https://github.com/python/cpython/pull/158602/files
Please reload this pagehttps://github.com/python/cpython/pull/158602/files
Please reload this pagehttps://github.com/python/cpython/pull/158602/files
2026-10-02-16-19-35.gh-issue-158592.V6W21J.rst https://github.com/python/cpython/pull/158602/files#diff-d4e825793066d3d9f351dd74efb017a8671fcadf0c6105ecd957c8fc7abc5a03
listobject.c https://github.com/python/cpython/pull/158602/files#diff-67a42c5c0990c7aceea040ffc07905299aab97d64dc49adb256f85340b2c7e81
Misc/NEWS.d/next/Core_and_Builtins/2026-10-02-16-19-35.gh-issue-158592.V6W21J.rsthttps://github.com/python/cpython/pull/158602/files#diff-d4e825793066d3d9f351dd74efb017a8671fcadf0c6105ecd957c8fc7abc5a03
View file https://github.com/x42005e1f/cpython/blob/ad8cdb7c184126f43c811a4a94f667e2ead28858/Misc/NEWS.d/next/Core_and_Builtins/2026-10-02-16-19-35.gh-issue-158592.V6W21J.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158602/{{ revealButtonHref }}
Objects/listobject.chttps://github.com/python/cpython/pull/158602/files#diff-67a42c5c0990c7aceea040ffc07905299aab97d64dc49adb256f85340b2c7e81
View file https://github.com/x42005e1f/cpython/blob/ad8cdb7c184126f43c811a4a94f667e2ead28858/Objects/listobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/158602/{{ revealButtonHref }}
https://github.com/python/cpython/pull/158602/files#diff-67a42c5c0990c7aceea040ffc07905299aab97d64dc49adb256f85340b2c7e81
https://github.com/python/cpython/pull/158602/files#diff-67a42c5c0990c7aceea040ffc07905299aab97d64dc49adb256f85340b2c7e81
Please reload this pagehttps://github.com/python/cpython/pull/158602/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.