Class attribute tables #989
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 410 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.360
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #989"
general
weight: 0.35
jaheba
Depends on #1050; this PR targets
dh/either-strand builds on itsPyStrview.Define Python-visible builtin attributes alongside their Rust implementations using
#[pyattrs].Receivernames the actual native view passed to a method.String methods are defined directly on
PyStr, covering both interned and heap strings:Attribute definitions and receivers
The macro emits an inherent implementation containing the functions, a
PyAttrsimplementation withconst ATTRS: &'static [(StaticStrings, AttrDef)], and a constlookup_attrmatch returning entries from that table.Rust names determine attribute names:
uppermaps toStaticStrings::Upper, andtotal_secondstoTotalSeconds.#[pymethod]registers a method and generates its adapter from&Valueto the native receiver.#[pyclassmethod]registers a class-method callable.#[pyvalue]registers a value factory.Receivercan be aHeapRead<'h, T>,HeapObjectRead<'h, T>,PyStr<'h>, or an immediatef64,i64, orbool.Heap methods select
&or&mutin their explicit first parameter; string methods take&PyStr.Adapters remain callable for any VM lifetime, independently of the lifetime used to select the attribute table.
Other builtin methods use zero-sized namespaces such as
PyListImpl, which are never instantiated or stored in the heap.Dispatch and scope
The centralized
attrs(owner: Type)selects each type's trait constant.py_call_attrand class-method dispatch use static lookups, with enumerable, const-compatible tables.There is no runtime registry or dynamic discovery.
This covers 102 attributes across str, list, tuple, complex, date, time, timedelta, timezone, regex patterns, and regex matches.
All 44 existing string methods use the generated table.
Single-use string implementations are inlined into their registered methods; shared startswith/endswith validation remains
an unregistered helper on
PyStr.Existing argument handling, error propagation, heap borrowing, and reference management are retained.
List sorting keeps its reentrancy handling and modification detection.
Native object representations, bytecode, serialization, and the dump version are unchanged by this PR.
Standalone callable attributes are separate follow-up work.
Validation
and duplicate trait implementations.