Share element access for lists and tuples #1411
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 416 lines diff across 5 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.361
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1411"
general
weight: 0.35
davidhewitt
Summary
List and tuple fast paths now read elements through
SequenceItems. The view exposes length, per-item access, andowned copies so callers can work with compact buffers that construct a
Valueon demand.Move bulk insertion, swaps, and GC child traversal into
Listmethods. Host export still copies the list's elementsbefore recursing because a nested
__repr__can mutate the source list.This refactor prepares for the storage strategies explored in #1025.
Tests
memory-model-checksandtest-hooks32bbc255<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Encapsulates list, tuple, and namedtuple element access behind a
SequenceItemsread-only view, moving bulk insertion, swaps, list concatenation, and GC child traversal intoListmethods in preparation for the storage strategies in #1025.SequenceItemswith indexed (map_item,clone_item) and iterator access producing ownedValues on demand; callers restrict which heap types the view accepts, with tuple-only lookups (from_tuple) for dict item membership and named-tuple concatenation.SequenceItemsandListmethods (extend_owned,swap,for_each_child_id);list.extend, in-place concatenation, starred unpacking,Callable,Decimal, dict item membership,sorted, JSON separators, and package paths reuse owned reads.sortedkeeps its periodic deadline check while copying; the CSV writer now copies directive fields through the same guarded loop so a timeout releases their heap references.DictViewaccepts namedtuples of length two as candidate key/value pairs.ValueError: too many values to unpack (expected 1, got 2); CPython omitsgot 2for named tuples, so the divergence is documented.__repr__can mutate the source list.DecimalwithDecimalTuple,csv.writerrows, and a non-sequence import path.<sup>Written for commit 1c5703053726184dc41a308f3874e5318810deb6. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1411?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. -->