Skip to content

Commit 3a702ac

Browse files
morealclaude
andauthored
Improve json.loads performance (#6704)
* Parse JSON in Rust * Reuse key when decoding JSON * Unmark resolved test * Parse null/true/false directly in call_scan_once Parse JSON constants (null, true, false) directly in Rust within call_scan_once() instead of falling back to Python scan_once. This reduces Python-Rust boundary crossings for array/object values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Parse numbers directly in call_scan_once Parse JSON numbers starting with digits (0-9) directly in Rust within call_scan_once() by reusing the existing parse_number() method. This reduces Python-Rust boundary crossings for array/object values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Parse NaN/Infinity/-Infinity in call_scan_once Parse special JSON constants (NaN, Infinity, -Infinity) and negative numbers directly in Rust within call_scan_once(). This handles: - 'N' -> NaN via parse_constant callback - 'I' -> Infinity via parse_constant callback - '-' -> -Infinity or negative numbers via parse_constant/parse_number This reduces Python-Rust boundary crossings for array/object values. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Correct wrong index access * Leave more flame span * Refactor json scanstring with byte index --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c5deb74 commit 3a702ac

File tree

3 files changed

+587
-73
lines changed

3 files changed

+587
-73
lines changed

Lib/test/test_json/test_decode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ def test_limit_int(self):
138138
class TestPyDecode(TestDecode, PyTest): pass
139139

140140
class TestCDecode(TestDecode, CTest):
141-
# TODO: RUSTPYTHON
142-
@unittest.expectedFailure
143141
def test_keys_reuse(self):
144142
return super().test_keys_reuse()
145143

0 commit comments

Comments
 (0)