Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-137821: Convert _json module to use Argument Clinic#140778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
hnnynh commented Oct 30, 2025 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
Uh oh!
There was an error while loading. Please reload this page.
hnnynh commented Oct 30, 2025 • edited by corona10
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by corona10
Uh oh!
There was an error while loading. Please reload this page.
encode_basestring_medium: Mean +- std dev: [base] 2.11 us +- 0.05 us -> [ac] 2.33 us +- 0.04 us: 1.11x slower encode_basestring_medium_escapes: Mean +- std dev: [base] 15.3 us +- 0.4 us -> [ac] 17.6 us +- 0.2 us: 1.15x slower scanstring_medium: Mean +- std dev: [base] 158 ns +- 2 ns -> [ac] 110 ns +- 2 ns: 1.43x faster Benchmark hidden because not significant (4): encode_basestring_ascii_medium, encode_basestring_ascii_medium_escapes, encode_basestring_ascii_medium_unicode, encode_basestring_medium_unicode Geometric mean: 1.02x faster
importpyperfimport_json# Test data - medium objects (typical API responses)medium_string="The quick brown fox jumps over the lazy dog. "*20# ~900 charsmedium_string_with_escapes='''Line 1: "status": "success"Line 2: Response received at 2024-01-15T10:30:00Z\tError code: null\tMessage: "Operation completed successfully"'''*50medium_unicode="User: 김철수 | Email: user@example.com | Status: ✓ Active | Location: 東京都 | Rating: ★★★★☆ | "*30medium_json_string='"'+'{"id": 12345, "name": "John Doe", "email": "john@example.com"}'*20+'"'defbench_encode_basestring_ascii(s): return_json.encode_basestring_ascii(s) defbench_encode_basestring(s): return_json.encode_basestring(s) defbench_scanstring(s): # scanstring takes (string, end, strict=True)# end is the index after the opening quotereturn_json.scanstring(s, 1, True) runner=pyperf.Runner() # encode_basestring_ascii benchmarksrunner.bench_func("encode_basestring_ascii_medium", bench_encode_basestring_ascii, medium_string) runner.bench_func("encode_basestring_ascii_medium_escapes", bench_encode_basestring_ascii, medium_string_with_escapes) runner.bench_func("encode_basestring_ascii_medium_unicode", bench_encode_basestring_ascii, medium_unicode) # encode_basestring benchmarksrunner.bench_func("encode_basestring_medium", bench_encode_basestring, medium_string) runner.bench_func("encode_basestring_medium_escapes", bench_encode_basestring, medium_string_with_escapes) runner.bench_func("encode_basestring_medium_unicode", bench_encode_basestring, medium_unicode) # scanstring benchmarksrunner.bench_func("scanstring_medium", bench_scanstring, medium_json_string) |
hnnynh commented Oct 30, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
I've checked the memory leak test. > ./python.exe -m test test_json -R3:3 Using random seed: 2482685647 0:00:00 load avg: 5.30 Run 1 test sequentially in a single process 0:00:00 load avg: 5.30 [1/1] test_json beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more) 123:456 XX. ... 0:00:30 load avg: 4.92 [1/1] test_json passed in 30.6 sec == Tests result: SUCCESS == 1 test OK. Total duration: 30.6 sec Total tests: run=203 skipped=3 Total test files: run=1/1 Result: SUCCESS |
corona10 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, parsing overhead does not exists and it becomes better!
Uh oh!
There was an error while loading. Please reload this page.
Misc/NEWS.d/next/Core_and_Builtins/2025-10-30-15-33-07.gh-issue-137821.8_Iavt.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
…e-137821.8_Iavt.rst
Misc/NEWS.d/next/Core_and_Builtins/2025-10-30-15-33-07.gh-issue-137821.8_Iavt.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
…e-137821.8_Iavt.rst
Misc/NEWS.d/next/Core_and_Builtins/2025-10-30-15-33-07.gh-issue-137821.8_Iavt.rst Outdated Show resolvedHide resolved
Uh oh!
There was an error while loading. Please reload this page.
…e-137821.8_Iavt.rst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to Library.
corona10Oct 30, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@StanFromIreland I will change it to following PR.
(Need some improvement)
25bd72d into python:mainUh oh!
There was an error while loading. Please reload this page.
bedevere-bot commented Oct 30, 2025
|
corona10 commented Oct 30, 2025
For the record, with #140780 |
_jsonto Argument Clinic #137821