Prototype Python signatures for native callables #1391
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 · 484 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.370
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1391"
general
weight: 0.35
jaheba
This prototype lets a native callable declare its Python signature beside its Rust implementation. The macro generates the argument struct and its
FromArgsimplementation.Here
oldandnewborrow the caller’s string data, andcountaccepts objects implementing__index__. str.replace implementationTwo existing conversions in the prototype still differ from the base branch.
math.iscloseaccepts user-defined numeric conversions such as__float__. For an integer separator,str.splitreportsmust be str or None, not intwhere the base reportsexpected str.I’d like feedback on whether this declaration is easier to maintain than an explicit Rust argument struct. One case where the choice is less clear is
str.split: when both arguments are invalid, CPython checksmaxsplitbeforesep. The prototype spells thatcheck_last = sep. Would you keep that rule in the attribute or write the conversion explicitly in the implementation? str.split implementationThis builds on #1387 for scoped cleanup of bound arguments. The upstream diff includes that open PR. Review just the signature changes.
Local validation passed for 127 unit tests and 1,572 Monty and CPython fixture checks.
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Prototypes
#[py_signature], letting a native callable declare its Python signature beside its Rust implementation. The macro generates the argument struct, itsFromArgsbinding, and the descriptor used for runtime inspection.print,str.split,str.replace,zip_longest, JSONdump/dumps,Counter.update/subtract,dict.update,math.isclose, andos.urandomto the macro.SupportsIndexparameters now accept objects implementing__index__, and the migrated callables expose__text_signature__to Python.vm.scope/Local(the pending #1387 scoped-cleanup work); the upstream diff includes that PR, so review just the signature changes.Open question: when both
sepandmaxsplitare invalid, CPython reportsmaxsplitfirst.str.splitspells that withcheck_last = sep; I'd like to know whether that rule belongs in the attribute or should be written explicitly in the implementation.Local validation passes 127 unit tests and 1,572 Monty and CPython fixture checks.
<sup>Written for commit 60471effc8f5beb64e5984502b4d6333de7501a0. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/pydantic/monty/pull/1391?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. -->