Problem
json_to_bound (rust/src/claims.rs:122-126) allocates a fresh PyString for every dict key on every decode, including the same standard claim / header names each time.
Proposal
Use pyo3::intern! (or a small static table) for common keys — exp, iat, nbf, sub, aud, iss, jti, alg, typ, kid — and fall back to a new PyString otherwise. Interned keys also make subsequent dict.get in Python hit the pointer-equality fast path.
Follow-up to consider (measure first): deserialize payload JSON straight into Python objects via a serde visitor, skipping the intermediate serde_json::Value (claims validation would need to move to a borrowed view or a lightweight struct).
Acceptance criteria
Files
Branch
issue/<N>-intern-claim-keys from dev
Problem
json_to_bound(rust/src/claims.rs:122-126) allocates a freshPyStringfor every dict key on every decode, including the same standard claim / header names each time.Proposal
Use
pyo3::intern!(or a small static table) for common keys —exp,iat,nbf,sub,aud,iss,jti,alg,typ,kid— and fall back to a newPyStringotherwise. Interned keys also make subsequentdict.getin Python hit the pointer-equality fast path.Follow-up to consider (measure first): deserialize payload JSON straight into Python objects via a serde visitor, skipping the intermediate
serde_json::Value(claims validation would need to move to a borrowed view or a lightweight struct).Acceptance criteria
Files
rust/src/claims.rsBranch
issue/<N>-intern-claim-keysfromdev