I’ve been profiling per-request cost in a Lambda-based service that uses cedarpy with a static, code-checked policy set, and the per-call PolicySet::from_str inside is_authorized is showing up as the dominant cost. On the same machine I’m seeing ~1 ms per call against a 16 KB policy file vs ~0.07 ms with a single-permit policy, so the parse really is most of the work.
Since cedar_policy::Authorizer::is_authorized already takes &PolicySet directly, I’m wondering whether you’d be open to exposing a Python-side PolicySet (e.g. PolicySet.from_str(...)) that is_authorized and is_authorized_batch could accept alongside str. So backwards compatible. Callers whose policies are static could then parse once and reuse the object for the lifetime of the process.
I would be happy to create a PR if there is interest.
I’ve been profiling per-request cost in a Lambda-based service that uses cedarpy with a static, code-checked policy set, and the per-call
PolicySet::from_strinsideis_authorizedis showing up as the dominant cost. On the same machine I’m seeing ~1 ms per call against a 16 KB policy file vs ~0.07 ms with a single-permit policy, so the parse really is most of the work.Since
cedar_policy::Authorizer::is_authorizedalready takes&PolicySetdirectly, I’m wondering whether you’d be open to exposing a Python-side PolicySet (e.g.PolicySet.from_str(...)) that is_authorized and is_authorized_batch could accept alongside str. So backwards compatible. Callers whose policies are static could then parse once and reuse the object for the lifetime of the process.I would be happy to create a PR if there is interest.