Title: Avoid redundant whitespace scan in json.loads() for documents without surrounding whitespace · Issue #150860 · python/cpython · GitHub
Open Graph Title: Avoid redundant whitespace scan in json.loads() for documents without surrounding whitespace · Issue #150860 · python/cpython
X Title: Avoid redundant whitespace scan in json.loads() for documents without surrounding whitespace · Issue #150860 · python/cpython
Description: Decoding a JSON document with json.loads() runs a whitespace-skipping regular expression at the start and end of the document through the pure-Python decode() wrapper, on every call, before and after the C scanner does the actual parsing...
Open Graph Description: Decoding a JSON document with json.loads() runs a whitespace-skipping regular expression at the start and end of the document through the pure-Python decode() wrapper, on every call, before and aft...
X Description: Decoding a JSON document with json.loads() runs a whitespace-skipping regular expression at the start and end of the document through the pure-Python decode() wrapper, on every call, before and aft...
Opengraph URL: https://github.com/python/cpython/issues/150860
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Avoid redundant whitespace scan in json.loads() for documents without surrounding whitespace","articleBody":"Decoding a JSON document with `json.loads()` runs a whitespace-skipping regular expression at the start and end of the document through the pure-Python `decode()` wrapper, on every call, before and after the C scanner does the actual parsing. The overwhelming majority of documents have no leading or trailing whitespace, so both matches scan zero characters yet still pay for the call and the match-object allocation. For the small documents that dominate real traffic, that fixed overhead is a meaningful fraction of the total decode time.\n\nSkipping the leading match when the document does not begin with whitespace, and the trailing match when the parse already consumed the whole string, removes that overhead from the common case. On a tiny document it is roughly 1.5x faster; documents that do have surrounding whitespace keep the original behavior, and large documents are unaffected.\n\nThis overlaps with the broader rewrite proposed in gh-117397; it is filed separately so the small, self-contained version can be evaluated on its own.\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-150861\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gaborbernat","@type":"Person","name":"gaborbernat"},"datePublished":"2026-06-03T14:29:45Z","url":"https://github.com/python/cpython/issues/150860"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:60083123-9236-c8e8-0e5b-2fe7fb8846bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6B0:2A5566:193EEC7:2118B74:6B02096B |
| html-safe-nonce | 05a5de6133c08ae8b26e1e16e2151246da065df0159f40b5cc0f169b9db06a13 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkIwOjJBNTU2NjoxOTNFRUM3OjIxMThCNzQ6NkIwMjA5NkIiLCJ2aXNpdG9yX2lkIjoiNzY0MTQxMjM0Mzc0MTY3OTk3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 835f468d78d49390eab779a16c2dacab49796a4f252a350f3a06ec6b646f5b10 |
| hovercard-subject-tag | issue:4580789707 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/150860/issue_layout |
| twitter:image | https://opengraph.githubassets.com/813ffba5895d120106937305df12a899357929760501a6282a832c0c5ad694f0/python/cpython/issues/150860 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/813ffba5895d120106937305df12a899357929760501a6282a832c0c5ad694f0/python/cpython/issues/150860 |
| og:image:alt | Decoding a JSON document with json.loads() runs a whitespace-skipping regular expression at the start and end of the document through the pure-Python decode() wrapper, on every call, before and aft... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gaborbernat |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width