René's URL Explorer Experiment


Title: gh-150942: Speed up csv.reader row building by omkar-334 · Pull Request #150995 · python/cpython · GitHub

Open Graph Title: gh-150942: Speed up csv.reader row building by omkar-334 · Pull Request #150995 · python/cpython

X Title: gh-150942: Speed up csv.reader row building by omkar-334 · Pull Request #150995 · python/cpython

Description: Use _PyList_AppendTakeRef while collecting fields in csv.reader instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per parsed field. Microbenchmarks Release build, macOS Benchmark main this PR speedup csv_reader_2m_fields 86.96 ms 79.23 ms 1.10x csv_reader_400k_fields_8col 17.15 ms 16.26 ms 1.05x csv_reader_80k_fields 3.17 ms 2.89 ms 1.10x geomean 1.08x Benchmark script """Micro-benchmark for csv.reader field-append hot path. Generates an in-memory CSV with many fields per row, then times how long it takes to iterate the reader fully. Repeats N trials, reports min/median/mean so noise is visible. Writes per-trial timings to results/. """ from __future__ import annotations import argparse import csv import io import json import statistics import sys import time from pathlib import Path def make_csv(rows: int, cols: int) -> str: buf = io.StringIO() w = csv.writer(buf) for r in range(rows): w.writerow([f"v{r}_{c}" for c in range(cols)]) return buf.getvalue() def time_reader(data: str) -> float: t0 = time.perf_counter_ns() for _ in csv.reader(io.StringIO(data)): pass return (time.perf_counter_ns() - t0) / 1e9 def main() -> int: ap = argparse.ArgumentParser() ap.add_argument("--rows", type=int, default=20_000) ap.add_argument("--cols", type=int, default=20) 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/gh-150942") args = ap.parse_args() data = make_csv(args.rows, args.cols) size_bytes = len(data.encode()) field_count = args.rows * args.cols for _ in range(args.warmup): time_reader(data) trials = [time_reader(data) for _ in range(args.trials)] outdir = Path(args.outdir) outdir.mkdir(parents=True, exist_ok=True) summary = { "label": args.label, "python": sys.executable, "rows": args.rows, "cols": args.cols, "trials": args.trials, "warmup": args.warmup, "field_count": field_count, "input_bytes": size_bytes, "seconds": { "min": min(trials), "median": statistics.median(trials), "mean": statistics.fmean(trials), "stdev": statistics.pstdev(trials), "all": trials, }, "fields_per_sec_at_min": field_count / 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"fields/s@min={summary['fields_per_sec_at_min']:.2e}" ) print(f"wrote {out}") return 0 if __name__ == "__main__": raise SystemExit(main())

Open Graph Description: Use _PyList_AppendTakeRef while collecting fields in csv.reader instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per parsed field. Microbenchmarks Release build, macOS...

X Description: Use _PyList_AppendTakeRef while collecting fields in csv.reader instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per parsed field. Microbenchmarks Release build, macOS...

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

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:72d0913a-f02a-8a97-9497-466ec4d0200e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9752:F7C4C:34854A0:464F644:6B020B14
html-safe-nonce2f30b0624a2edf431cd72d2844a2f0090c4cf49f586031be06256d9493c31586
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzUyOkY3QzRDOjM0ODU0QTA6NDY0RjY0NDo2QjAyMEIxNCIsInZpc2l0b3JfaWQiOiI0OTQ2MzYzNDQ4MzE4NjI2NTgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac1384b778c4eaed602f18f7bbe8c5f7e6897af32be15fcb547048bb2c08df710f
hovercard-subject-tagpull_request:3813951194
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/150995/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 fields in csv.reader instead of PyList_Append followed by Py_DECREF, removing an incref/decref pair per parsed field. Microbenchmarks Release build, macOS...
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/150995/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F150995%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%2F150995%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/150995/files
Reloadhttps://github.com/python/cpython/pull/150995/files
Reloadhttps://github.com/python/cpython/pull/150995/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
omkar-334https://github.com/omkar-334
python:mainhttps://github.com/python/cpython/tree/main
omkar-334:gh-150942-csv-appendtakerefhttps://github.com/omkar-334/cpython/tree/gh-150942-csv-appendtakeref
Conversation 8 https://github.com/python/cpython/pull/150995
Commits 6 https://github.com/python/cpython/pull/150995/commits
Checks 51 https://github.com/python/cpython/pull/150995/checks
Files changed 2 https://github.com/python/cpython/pull/150995/files
gh-150942: Speed up csv.reader row building https://github.com/python/cpython/pull/150995/files#top
Show all changes 6 commits https://github.com/python/cpython/pull/150995/files
7945e61 gh-150942: Speed up csv.reader row building omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/150995/commits/7945e6107b964bae6467d3275feffa2924d01b28
1c00c00 Merge branch 'main' into gh-150942-csv-appendtakeref omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/150995/commits/1c00c000361f515f924fd7f33c04ac1980ddce2e
ed09dac add patch contributor name omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/150995/commits/ed09daca6aab6d8909ff2e2d92f92d14c3537fb4
b29bdae Merge branch 'main' into gh-150942-csv-appendtakeref omkar-334 Jun 6, 2026 https://github.com/python/cpython/pull/150995/commits/b29bdaec18e5ddd8725cb2bb6ac18d81dd915d1f
9c6be23 simpify news entry omkar-334 Aug 19, 2026 https://github.com/python/cpython/pull/150995/commits/9c6be23ea2f8bf80f6bece7d3cefcd8c732e0afb
d695bf9 Merge branch 'main' into gh-150942-csv-appendtakeref omkar-334 Aug 19, 2026 https://github.com/python/cpython/pull/150995/commits/d695bf9f4ccb4deb8981da9867a76920a71cb194
Clear filters https://github.com/python/cpython/pull/150995/files
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
2026-06-05-12-00-00.gh-issue-150942.Hkdh87.rst https://github.com/python/cpython/pull/150995/files#diff-59d80614de35c85c7444e5cd8211d8e6bd6a74ecf2b3d254a94f30b0b8133b49
_csv.c https://github.com/python/cpython/pull/150995/files#diff-38fcce6bb475616052f5c9a0973eefd49489a4dff719f30e407534258e2a3ec3
Misc/NEWS.d/next/Library/2026-06-05-12-00-00.gh-issue-150942.Hkdh87.rsthttps://github.com/python/cpython/pull/150995/files#diff-59d80614de35c85c7444e5cd8211d8e6bd6a74ecf2b3d254a94f30b0b8133b49
View file https://github.com/python/cpython/blob/d695bf9f4ccb4deb8981da9867a76920a71cb194/Misc/NEWS.d/next/Library/2026-06-05-12-00-00.gh-issue-150942.Hkdh87.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150995/{{ revealButtonHref }}
Modules/_csv.chttps://github.com/python/cpython/pull/150995/files#diff-38fcce6bb475616052f5c9a0973eefd49489a4dff719f30e407534258e2a3ec3
View file https://github.com/python/cpython/blob/d695bf9f4ccb4deb8981da9867a76920a71cb194/Modules/_csv.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150995/{{ revealButtonHref }}
https://github.com/python/cpython/pull/150995/files#diff-38fcce6bb475616052f5c9a0973eefd49489a4dff719f30e407534258e2a3ec3
https://github.com/python/cpython/pull/150995/files#diff-38fcce6bb475616052f5c9a0973eefd49489a4dff719f30e407534258e2a3ec3
https://github.com/python/cpython/pull/150995/files#diff-38fcce6bb475616052f5c9a0973eefd49489a4dff719f30e407534258e2a3ec3
eendebakpthttps://github.com/eendebakpt
Jun 6, 2026https://github.com/python/cpython/pull/150995/files#r3366918345
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
omkar-334https://github.com/omkar-334
Jun 10, 2026https://github.com/python/cpython/pull/150995/files#r3385152499
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
omkar-334https://github.com/omkar-334
Jun 10, 2026https://github.com/python/cpython/pull/150995/files#r3385154126
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
omkar-334https://github.com/omkar-334
Jun 18, 2026https://github.com/python/cpython/pull/150995/files#r3439185258
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
@eendebakpthttps://github.com/eendebakpt
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
eendebakpthttps://github.com/eendebakpt
Jun 19, 2026https://github.com/python/cpython/pull/150995/files#r3441123162
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
@omkar-334https://github.com/omkar-334
Please reload this pagehttps://github.com/python/cpython/pull/150995/files
https://github.com/python/cpython/pull/150995/files#diff-38fcce6bb475616052f5c9a0973eefd49489a4dff719f30e407534258e2a3ec3
Please reload this pagehttps://github.com/python/cpython/pull/150995/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.