René's URL Explorer Experiment


Title: gh-150942: Speed up frame local item collection by omkar-334 · Pull Request #151002 · python/cpython · GitHub

Open Graph Title: gh-150942: Speed up frame local item collection by omkar-334 · Pull Request #151002 · python/cpython

X Title: gh-150942: Speed up frame local item collection by omkar-334 · Pull Request #151002 · python/cpython

Description: Use _PyList_AppendTakeRef while collecting frame-local (name, value) pairs instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per returned item pair. benchmarks Benchmark main this PR speedup frame_locals_items_100locals 9.09 ms 8.61 ms 1.06x frame_locals_items_1000locals 17.19 ms 16.59 ms 1.04x frame_locals_items_5000locals 29.92 ms 28.94 ms 1.03x geomean 1.04x Benchmark script """Micro-benchmark for frame.f_locals.items() result-list building.""" from __future__ import annotations import argparse import json import statistics import sys import time from pathlib import Path def make_frame(local_count: int): assignments = "\n".join(f" v{i} = {i}" for i in range(local_count)) src = ( "def make_frame():\n" f"{assignments}\n" " return sys._getframe()\n" ) ns = {"sys": sys} exec(src, ns) return ns["make_frame"]() def time_items(frame, loops: int) -> float: t0 = time.perf_counter_ns() for _ in range(loops): frame.f_locals.items() return (time.perf_counter_ns() - t0) / 1e9 def main() -> int: ap = argparse.ArgumentParser() ap.add_argument("--locals", type=int, default=1_000) ap.add_argument("--loops", type=int, default=2_000) ap.add_argument("--trials", type=int, default=15) ap.add_argument("--warmup", type=int, default=3) ap.add_argument("--label", default="run") ap.add_argument("--outdir", default="results/frame-locals-items") args = ap.parse_args() frame = make_frame(args.locals) item_count = len(frame.f_locals.items()) for _ in range(args.warmup): time_items(frame, args.loops) trials = [time_items(frame, args.loops) for _ in range(args.trials)] outdir = Path(args.outdir) outdir.mkdir(parents=True, exist_ok=True) summary = { "label": args.label, "python": sys.executable, "locals": args.locals, "item_count": item_count, "loops": args.loops, "trials": args.trials, "warmup": args.warmup, "items_built": item_count * args.loops, "seconds": { "min": min(trials), "median": statistics.median(trials), "mean": statistics.fmean(trials), "stdev": statistics.pstdev(trials), "all": trials, }, "items_per_sec_at_min": (item_count * args.loops) / min(trials), } out = outdir / f"bench_{args.label}.json" out.write_text(json.dumps(summary, indent=2)) s = summary["seconds"] print( f"{args.label}: min={s['min']*1000:.2f}ms median={s['median']*1000:.2f}ms " f"mean={s['mean']*1000:.2f}ms stdev={s['stdev']*1000:.2f}ms " f"items/s@min={summary['items_per_sec_at_min']:.2e}" ) print(f"wrote {out}") return 0 if __name__ == "__main__": raise SystemExit(main()) Issue: gh-150942

Open Graph Description: Use _PyList_AppendTakeRef while collecting frame-local (name, value) pairs instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per returned item pair. benchmarks Bench...

X Description: Use _PyList_AppendTakeRef while collecting frame-local (name, value) pairs instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per returned item pair. benchmarks Bench...

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

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:3bcd4dd3-550c-0a0a-b89d-6f5e97ec0b97
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC9A0:928E2:366730E:487F074:6B020C68
html-safe-nonce672795dc5b5cd144ca7d03cc74e552f233d97324e3089b2af5d886bac4d97ae3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUEwOjkyOEUyOjM2NjczMEU6NDg3RjA3NDo2QjAyMEM2OCIsInZpc2l0b3JfaWQiOiIxMDA1Mjc2NjE5NzEzMTU0MTUyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac62549a0092bca6b9d54e242a4f145af985ad60c452227a6271e9f4162d6b84d7
hovercard-subject-tagpull_request:3814159383
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/151002/files
twitter:imagehttps://avatars.githubusercontent.com/u/40126336?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40126336?s=400&v=4
og:image:altUse _PyList_AppendTakeRef while collecting frame-local (name, value) pairs instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per returned item pair. benchmarks Bench...
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/151002/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F151002%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%2F151002%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/151002/files
Reloadhttps://github.com/python/cpython/pull/151002/files
Reloadhttps://github.com/python/cpython/pull/151002/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
omkar-334:speed-up-frame-locals-itemshttps://github.com/omkar-334/cpython/tree/speed-up-frame-locals-items
Conversation 4 https://github.com/python/cpython/pull/151002
Commits 3 https://github.com/python/cpython/pull/151002/commits
Checks 57 https://github.com/python/cpython/pull/151002/checks
Files changed 2 https://github.com/python/cpython/pull/151002/files
gh-150942: Speed up frame local item collection https://github.com/python/cpython/pull/151002/files#top
Show all changes 3 commits https://github.com/python/cpython/pull/151002/files
52f8cf0 Speed up frame local item collection omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/151002/commits/52f8cf07f7b48371a64584a00531fbf17cbc9dc1
8b20fe3 add patch contributor name omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/151002/commits/8b20fe3a9ff0be821d0f1f844b5425afab2ff9bf
680bbd9 Merge branch 'main' into speed-up-frame-locals-items omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/151002/commits/680bbd969597b4432c2e270850aa75a8cfa28d35
Clear filters https://github.com/python/cpython/pull/151002/files
Please reload this pagehttps://github.com/python/cpython/pull/151002/files
Please reload this pagehttps://github.com/python/cpython/pull/151002/files
2026-06-06-08-20-00.gh-issue-150942.Jk9pQr.rst https://github.com/python/cpython/pull/151002/files#diff-14dcf28f5ccdaaf6ff3615b6c100cd0aeda8a6068b88be021aa1516490fa639a
frameobject.c https://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-08-20-00.gh-issue-150942.Jk9pQr.rsthttps://github.com/python/cpython/pull/151002/files#diff-14dcf28f5ccdaaf6ff3615b6c100cd0aeda8a6068b88be021aa1516490fa639a
View file https://github.com/omkar-334/cpython/blob/680bbd969597b4432c2e270850aa75a8cfa28d35/Misc/NEWS.d/next/Core_and_Builtins/2026-06-06-08-20-00.gh-issue-150942.Jk9pQr.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151002/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L213
Objects/frameobject.chttps://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
View file https://github.com/omkar-334/cpython/blob/680bbd969597b4432c2e270850aa75a8cfa28d35/Objects/frameobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/151002/{{ revealButtonHref }}
https://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
https://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
https://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
https://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
https://github.com/python/cpython/pull/151002/files#diff-7b8cef249e5cca077d30de4e428a6bde6b9b803464e790e9cffa7e052e19efdd
Please reload this pagehttps://github.com/python/cpython/pull/151002/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.