Start list and tuple index searches at the requested offset #1270
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 535 lines diff across 6 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.376
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1270"
general
weight: 0.35
jaheba
list.index(value, start, end)andtuple.index(...)currently advance their lending iterators from zero, cloning and dropping excluded prefix values before searching the requested window. Initialize the existing iterator position from the normalized start instead.Keep the existing bounds-coercion order, mutation-safe list reads, comparison path, recursion guard and native timeout polling. Comments explain why excluded entries need no equality calls or reference-count traffic. Tests cover huge/negative bounds, bound coercions that mutate the list, equality callbacks that clear it, empty windows, shared children and callback-driven timeouts.
Microbenchmarks were measured on macOS 27 arm64 with Rust 1.99.0 release builds (fat LTO, one codegen unit), clean main
5bcc54cdversus2d8790f4. Both binaries were built in the same directory and frozen before timing. Flying Circus ran 40 randomized samples per runtime/mode, serially, with 10 repeated-mode warmups and no builds or tests running alongside measurements. These repeated-worker medians include compilation, setup and execution of the full script, excluding process startup. Scripts were validated with CPython 3.14.2; every measured request checked its assertions and expected output. Benchmark scripts are kept local and are not part of this PR; input sizes and operation counts are listed below.| Microbenchmark | Main | Candidate | Time change |
| --- | ---: | ---: | ---: |
| 1,000 tail-only searches of a 4,096-item list | 21.4779 ms | 0.2497 ms | -98.84% (86.0x faster) |
| 1,000 tail-only searches of a 4,096-item tuple | 22.5905 ms | 0.2272 ms | -98.99% (99.4x faster) |
| 100 full-range list searches, integer items | 8.5458 ms | 8.4614 ms | -0.99% |
| 200 full-range list searches, heap-string items | 5.5771 ms | 5.6073 ms | +0.54% |
The full-range controls fall below the configured change threshold in repeated mode. The large gains come from eliminating the excluded prefix; they describe these offset-heavy workloads.
The harness used protocol 7 transport compatibility. Timing flags were
--diff --samples 40 --warmups 10 --startup-samples 3 --memory-samples 0 --threshold 1 --absolute-threshold-ms 0.01 -x 1, with each script passed using--benchmarkand baseline/candidate passed using-r.Local validation passed: all 1,492 Monty/CPython fixture checks, all 142 reference-count fixture checks, 95 Rust tests across collections, container mutation, dump compatibility, resource limits and the new callback-timeout test, Clippy with warnings denied, Ruff, formatting and import checks. Rust tests and fixtures used
memory-model-checks; the reference-count pass also usedref-count-return.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Starts
list.index(value, start, end)andtuple.index(...)searches at the normalizedstartoffset instead of cloning and dropping the excluded prefix entries from zero, which dominated the cost when the needle sat near the end. Also checks the native timeout budget before the search so nested short offset searches can't outrun an expired limit.<sup>Written for commit 4b0b7aef7f139bea3e50884b5e42169680b9d51f. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1270?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. -->