Return at once when repeating an empty list or deque #1282
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.44) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 248 lines diff across 3 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.330
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1282"
general
weight: 0.35
davidhewitt
[] nruns the clone loop inpy_mul_implntimes over an empty slice, since the size preflight passes when0 nis 0.[] 240does not return; CPython returns[]at once.deque() nwithout amaxlenhas the same loop inrepeat_deque.The tuple path already returns early for
count == 0 || len == 0.This PR:
py_mul_implinlist.rs;countto 0 for an empty source inrepeat_deque;[] 240anddeque() 2*40tolist__ops.pyandcollections__deque.py(both time out without the fix),plus
[] 2*63still raisingOverflowErroranddeque(maxlen=3) 2*40.No
limitations/change: the behaviour now matches CPython.<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Fixes
[] nanddeque() nwith empty operands so they return immediately, matching CPython's behavior.Previously,
[] 2*40anddeque() 2**40spun an empty loop overcountiterations and never returned. The tuple path already handled this; now the list path short-circuits directly andrepeat_dequeclamps the count to 0 for an empty source, while oversized counts still raiseOverflowErroras CPython does. Tests cover the immediate return for huge counts and the still-raisedOverflowErrorfor non-index-sized counts.<sup>Written for commit 1a6dc06f05852ab9b10d796b0db1fef311c290ac. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1282?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. -->