]> granicus.if.org Git - python/commit
bpo-37587: Make json.loads faster for long strings (GH-14752)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 30 Jul 2019 14:37:28 +0000 (07:37 -0700)
committerGitHub <noreply@github.com>
Tue, 30 Jul 2019 14:37:28 +0000 (07:37 -0700)
commit9265a877426af4fa5c44cc8482e0198806889350
tree5f49d205eade521ab615059960616e59e53d60ce
parent8b50e3e2729190d4b65ee9510d81f01bd31f2f7c
bpo-37587: Make json.loads faster for long strings (GH-14752)

When scanning the string, most characters are valid, so
checking for invalid characters first means never needing
to check the value of strict on valid strings, and only
needing to check it on invalid characters when doing
non-strict parsing of invalid strings.

This provides a measurable reduction in per-character
processing time (~11% in the pre-merge patch testing).
(cherry picked from commit 8a758f5b99c5fc3fd32edeac049d7d4a4b7cc163)

Co-authored-by: Marco Paolini <mpaolini@users.noreply.github.com>
Misc/NEWS.d/next/Library/2019-07-13-16-02-48.bpo-37587.fd-1aF.rst [new file with mode: 0644]
Modules/_json.c