René's URL Explorer Experiment


Title: gh-150638: Improve performance of json.loads and json.load for numeric data by eendebakpt · Pull Request #150639 · python/cpython · GitHub

Open Graph Title: gh-150638: Improve performance of json.loads and json.load for numeric data by eendebakpt · Pull Request #150639 · python/cpython

X Title: gh-150638: Improve performance of json.loads and json.load for numeric data by eendebakpt · Pull Request #150639 · python/cpython

Description: _match_number_unicode() (the C accelerator behind json.loads) previously allocated a PyBytes object for every number, copied the digits into it, and then called the generic PyLong_FromString / PyFloat_FromString parsers. This PR parses the common cases directly from the already-scanned text. Benchmark main this PR speedup json.loads, number-heavy document (script below) 3.05 ms 2.38 ms 1.28× json.load, same document via file object 3.17 ms 2.48 ms 1.28× pyperformance bm_json_loads 25.2 µs 23.9 µs 1.05× The standard bm_json_loads document is string/dict-dominated, so it gains less. Also addresses #155742 Benchmark script """Benchmark json.loads() and json.load() on a number-heavy document. The document is generated deterministically at import time (no external files) and resembles a typical telemetry/API payload: a list of records mixing integers, 19-digit timestamps, negative integers, floats, short strings, booleans and small integer arrays. json.load(fp) is json.loads(fp.read()); here fp is an in-memory io.StringIO (rewound each call) so the same document is parsed without disk noise. Inline data size: ~304 KiB (2000 records). """ import io import json import pyperf def build_document(n=2000): return [ { "id": i, "timestamp": 1_700_000_000_000_000_000 + i * 1_000, # 19-digit int "value": i * 1.5 - 1000.0, # float "delta": -i, # negative int "label": "item-%d" % i, # short string "ok": i % 2 == 0, # bool "samples": [i, -i, i * 2, i * 3, i * 5], # int array } for i in range(n) ] JSON_DATA = json.dumps(build_document()) STREAM = io.StringIO(JSON_DATA) def load_from_stream(): STREAM.seek(0) return json.load(STREAM) if __name__ == "__main__": runner = pyperf.Runner() runner.metadata["description"] = "json.loads()/json.load() on a number-heavy document" runner.bench_func("json_loads", json.loads, JSON_DATA) runner.bench_func("json_load", load_from_stream) Issue: gh-150638

Open Graph Description: _match_number_unicode() (the C accelerator behind json.loads) previously allocated a PyBytes object for every number, copied the digits into it, and then called the generic PyLong_FromString / PyFl...

X Description: _match_number_unicode() (the C accelerator behind json.loads) previously allocated a PyBytes object for every number, copied the digits into it, and then called the generic PyLong_FromString / PyFl...

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

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:e832d861-0fc1-01c4-2cf2-818d824a5f13
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idEB42:110357:794A41:9E868C:6B025B32
html-safe-noncef3772c6e3759d1996a247453f022884f133315169d6f2ab473f908741ff57c50
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjQyOjExMDM1Nzo3OTRBNDE6OUU4NjhDOjZCMDI1QjMyIiwidmlzaXRvcl9pZCI6IjI4MDE0ODU3ODg5MDUzNjQyNzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac686f24a86a43f84afd6d331a6da8a2c62aca22bc84ffb3d38481ccb68f6078e1
hovercard-subject-tagpull_request:3774950357
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/150639/files
twitter:imagehttps://avatars.githubusercontent.com/u/883786?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/883786?s=400&v=4
og:image:alt_match_number_unicode() (the C accelerator behind json.loads) previously allocated a PyBytes object for every number, copied the digits into it, and then called the generic PyLong_FromString / PyFl...
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/150639/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F150639%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%2F150639%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/150639/files
Reloadhttps://github.com/python/cpython/pull/150639/files
Reloadhttps://github.com/python/cpython/pull/150639/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
eendebakpthttps://github.com/eendebakpt
python:mainhttps://github.com/python/cpython/tree/main
eendebakpt:json-loads-opthttps://github.com/eendebakpt/cpython/tree/json-loads-opt
Conversation 10 https://github.com/python/cpython/pull/150639
Commits 18 https://github.com/python/cpython/pull/150639/commits
Checks 53 https://github.com/python/cpython/pull/150639/checks
Files changed https://github.com/python/cpython/pull/150639/files
Please reload this pagehttps://github.com/python/cpython/pull/150639/files
gh-150638: Improve performance of json.loads and json.load for numeric data https://github.com/python/cpython/pull/150639/files#top
Show all changes 18 commits https://github.com/python/cpython/pull/150639/files
9010aac gh-XXXXX: Speed up json.loads number parsing eendebakpt May 30, 2026 https://github.com/python/cpython/pull/150639/commits/9010aac9cf93f1b5c9061ead6662c93eed3b83a5
b001f96 📜🤖 Added by blurb_it. blurb-it[bot] May 30, 2026 https://github.com/python/cpython/pull/150639/commits/b001f9628cee789f923936b5a40dbe9938ae4ae7
17d1971 gh-XXXXX: Add tests for json.loads number parsing edge cases eendebakpt May 30, 2026 https://github.com/python/cpython/pull/150639/commits/17d19712ec9f742a2a27c40aca1e4c7295878e4a
43f14d2 Merge remote-tracking branch 'origin/main' into json-loads-opt eendebakpt May 30, 2026 https://github.com/python/cpython/pull/150639/commits/43f14d23eb97a3cb5e3d8427adcab341fd276ee9
b0c486f Merge remote-tracking branch 'pte/json-loads-opt' into json-loads-opt eendebakpt May 30, 2026 https://github.com/python/cpython/pull/150639/commits/b0c486ffa014a7330dcf17b83d6aed9e14d4ae81
397f3e4 review comments eendebakpt Jun 11, 2026 https://github.com/python/cpython/pull/150639/commits/397f3e4febbe611517517c477109be10335e7306
a1b47fe Merge branch 'main' into json-loads-opt eendebakpt Jun 11, 2026 https://github.com/python/cpython/pull/150639/commits/a1b47fec841b5766d8cb9c797b4eb8040b7c5757
57b4dc0 pep7 eendebakpt Jun 15, 2026 https://github.com/python/cpython/pull/150639/commits/57b4dc016e62ad84d04eb7257ec75bc606e2299d
22f1cbf Merge branch 'main' into json-loads-opt eendebakpt Jun 15, 2026 https://github.com/python/cpython/pull/150639/commits/22f1cbfb891e2136edb97da0072a3a39efeac0fb
b5f5fc0 Apply suggestion from @eendebakpt eendebakpt Jun 15, 2026 https://github.com/python/cpython/pull/150639/commits/b5f5fc0a8a4926d7f5553c44bdd96487e349f8fc
d3cc3a7 Merge remote-tracking branch 'origin/main' into json-loads-opt eendebakpt Aug 5, 2026 https://github.com/python/cpython/pull/150639/commits/d3cc3a7d8a01b15a0a11baa80b95e9463d8ff4c7
45fac46 Merge branch 'json-loads-opt' into HEAD eendebakpt Aug 5, 2026 https://github.com/python/cpython/pull/150639/commits/45fac46fd0016868107346a7469d3614d0f7c98b
c14d806 pep7 eendebakpt Aug 5, 2026 https://github.com/python/cpython/pull/150639/commits/c14d8063e303475af844b3e291c9622b023bd036
f84dec8 Use PyMem_Malloc() instead of a temporary bytes object for long numbers eendebakpt Sep 19, 2026 https://github.com/python/cpython/pull/150639/commits/f84dec868b28a16364786cf3b8281668519406e0
6ec3ecd Merge branch 'main' into json-loads-opt eendebakpt Sep 21, 2026 https://github.com/python/cpython/pull/150639/commits/6ec3ecdfcfdd5d4810fb67bfd3323865f9dd9e60
ac137b7 Use signed accumulation for negative integers in the fast path eendebakpt Oct 19, 2026 https://github.com/python/cpython/pull/150639/commits/ac137b707d682ea2ba68c2ac48c008d5540fc116
fb4cd67 Merge branch 'main' into json-loads-opt eendebakpt Oct 19, 2026 https://github.com/python/cpython/pull/150639/commits/fb4cd679b67c5d1ebd7873bed492c6d9cd4e9331
8c6aeb8 Merge branch 'main' into json-loads-opt eendebakpt Nov 9, 2026 https://github.com/python/cpython/pull/150639/commits/8c6aeb8c4b4ddf4d0c0920d2de2b4623ecafbccd
Clear filters https://github.com/python/cpython/pull/150639/files
Please reload this pagehttps://github.com/python/cpython/pull/150639/files
Please reload this pagehttps://github.com/python/cpython/pull/150639/files
test_decode.py https://github.com/python/cpython/pull/150639/files#diff-bb9c9520a9c6971128d292b093d2ac0edce145a51e182d514b783d90cb25e8e2
2026-05-30-21-22-38.gh-issue-150638.LWR0QQ.rst https://github.com/python/cpython/pull/150639/files#diff-931998b3ac7ac1561b5b60b73c26e9c451110c6bac47038c1b3f508d029374fc
_json.c https://github.com/python/cpython/pull/150639/files#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39ed
Lib/test/test_json/test_decode.pyhttps://github.com/python/cpython/pull/150639/files#diff-bb9c9520a9c6971128d292b093d2ac0edce145a51e182d514b783d90cb25e8e2
View file https://github.com/python/cpython/blob/8c6aeb8c4b4ddf4d0c0920d2de2b4623ecafbccd/Lib/test/test_json/test_decode.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150639/{{ revealButtonHref }}
https://github.com/python/cpython/pull/150639/files#diff-bb9c9520a9c6971128d292b093d2ac0edce145a51e182d514b783d90cb25e8e2
https://github.com/python/cpython/pull/150639/files#diff-bb9c9520a9c6971128d292b093d2ac0edce145a51e182d514b783d90cb25e8e2
Misc/NEWS.d/next/Library/2026-05-30-21-22-38.gh-issue-150638.LWR0QQ.rsthttps://github.com/python/cpython/pull/150639/files#diff-931998b3ac7ac1561b5b60b73c26e9c451110c6bac47038c1b3f508d029374fc
View file https://github.com/python/cpython/blob/8c6aeb8c4b4ddf4d0c0920d2de2b4623ecafbccd/Misc/NEWS.d/next/Library/2026-05-30-21-22-38.gh-issue-150638.LWR0QQ.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150639/{{ revealButtonHref }}
Modules/_json.chttps://github.com/python/cpython/pull/150639/files#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39ed
View file https://github.com/python/cpython/blob/8c6aeb8c4b4ddf4d0c0920d2de2b4623ecafbccd/Modules/_json.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/150639/{{ revealButtonHref }}
https://github.com/python/cpython/pull/150639/files#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39ed
https://github.com/python/cpython/pull/150639/files#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39ed
https://github.com/python/cpython/pull/150639/files#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39ed
https://github.com/python/cpython/pull/150639/files#diff-efe183ae0b85e5b8d9bbbc588452dd4de80b39fd5c5174ee499ba554217a39ed
Please reload this pagehttps://github.com/python/cpython/pull/150639/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.