gh-156241: Add a no-escape fast path to the _json str escapers #156242
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 412 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.360
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #156242"
general
weight: 0.35
brittanyrey
ascii_escape_unicode()andescape_unicode()now return the input bulk-copied with surrounding quotes when nothing needs escaping, via a sharedquote_unescaped_unicode()helper, like the writer-basedwrite_escaped_ascii()/write_escaped_unicode()already do.| Benchmark | main | PR |
|---|---|---|
| dumps ascii 10 | 342 ns | 349 ns: ~same |
| dumps ascii 100 | 508 ns | 442 ns: 1.15x faster |
| dumps ascii 1 kB | 1.73 µs | 1.19 µs: 1.45x faster |
| dumps ascii 16 kB | 21.4 µs | 13.2 µs: 1.63x faster |
| dumps unicode 1 kB,
ensure_ascii=False| 3.04 µs | 1.80 µs: 1.69x faster || dump list of 100 strings | 23.2 µs | 21.1 µs: 1.10x faster |
| dumps escapes 100 | 531 ns | 520 ns: ~same |
| dumps list of 3 short strings | 1.30 µs | 1.29 µs: ~same |
<details>
<summary>Benchmark script</summary>
Run with
python bench_escape.py --fast -o out.jsonper build; compare withpyperf compare_to base.json branch.json --table.</details>
<!--
Thanks for your contribution!
Please read this comment in its entirety. It's quite important.
Pull Request title
It should be in the following format:
Where: gh-NNNNNN refers to the GitHub issue number.
Most PRs will require an issue number. Trivial changes, like fixing a typo, do not need an issue.
Backport Pull Request title
If this is a backport PR (PR made against branches other than
main),please ensure that the PR title is in the following format:
Where: [X.Y] is the branch name, for example: [3.13].
GH-NNNNNN refers to the PR number from
main.-->
<!-- gh-issue-number: gh-156241 -->
<!-- /gh-issue-number -->