Skip to content

perf: expose a reusable PolicySet to avoid re-parsing on every is_authorized call #83

Description

@Iamrodos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions