Borrow typed heap payloads with Value::get_as #1425
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.66) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.66 · 394 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.358
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.066
Real PR Conversation Timeline
1 comments
"Review active on #1425"
general
weight: 0.35
davidhewitt
Summary
value.get_as::<T>(heap)borrows a payload directly from the heap. For example, list indexing can useif let Some(slice) = key.get_as::<Slice>(vm.heap)to read the slice bounds. The result is tied to the heap borrow, and the lookup uses the existingHeap::getwithout creating a reader guard.This extracts the borrowed accessor from #1024 on top of #1421. The payload registry supplies the match for inline and boxed payloads. With the current untagged references, immediate values return
Nonebefore a heap lookup, and heap references need one lookup to check their payload type. The caller migrations cover single-type reads. Multi-type dispatch can continue matching several variants on a single heap lookup.Tests
Added a unit test that borrows bytes stored inline in a heap slot and a boxed named tuple. It also checks a mismatched heap payload and an immediate value. Ran the Monty tests and interpreter fixtures with
memory-model-checks, the workspace Rust lints, formatting, and the 32-bit WASI build check.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Adds
Value::get_as::<T>(heap)to borrow a typed heap payload directly, whileValueabsorbs borrowed accessors for bytes, strings, and long ints so call sites no longer matchValue::RefagainstHeapDatavariants by hand.get_asreuses the existingHeap::getlookup via the payload registry's newfrom_heap_data, checking the payload type for heap references and returningNonefor immediate values.Value::as_bytes,as_str,as_long_int, andtry_as_str(renamed fromtry_to_str) replace local helpers likevalue_as_bytes,str_of,buffer, and theis_long_int/long_intwrappers; codec inputs now borrow byte slices directly instead of copying throughvalue_to_owned_bytes.casefold=Trueaccepts mixed-case input; altchars translate before strict padding checks, and invalid digits take precedence over odd-length errors.ignorecharsnow charges the session for the input copy it makes during decoding.TypeError; CPython prefixes that message withmemoryview:forb32encode,b32hexencode,b85encode,z85encodeanda85encode.<sup>Written for commit ac80c7dd8385cdc33831a4f14640c7c49917094c. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1425?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. -->