Speed up Unicode string offset conversion #1315
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 350 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.351
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1315"
general
weight: 0.35
rewitt94
Speed up Unicode string indexing, slicing, and bounded searches by scanning from the nearer end of the string.
Short scans step through UTF-8 characters, while longer scans use SIMD or bulk counting.
Long scans poll the execution deadline, including when a heap string's character count is first computed.
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Speeds up Unicode string indexing, slicing, and bounded searches by scanning from the nearer string endpoint instead of always from the start, with cached character counts and ASCII status on string values.
Scanning
fast_offsets.rsscanner; the caller supplies the text's character count, an optional anchor, and a deadline callback.wide, and longer runs count withbytecount; forward and backward traversal share a bulk threshold of 128, or 512 when the whole string averages at least 1.5 UTF-8 bytes per code point.Layout and limits
HeapStr,InlineStr, andStringIteratormodules;Stris renamedHeapStr, andPyStrunifies string operations.u32::MAXbytes since parser offsets are 32-bit, raisingSyntaxErrorbeyond that.wideas a dependency, enablesbytecount's runtime-dispatch SIMD, and removesHeapBoxRead::as_box_value()from the heap-reader API.<sup>Written for commit c8903aa82606d973d6645d19771651017fdb81b9. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1315?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->