Skip to content

perf improvement : has_eval() in CoreEnforcer.enforce_ex #238

@etienne-lebrun

Description

@etienne-lebrun

Hello!
In a simple profile calling enforce a few times,looping over ~500 policies, I have noticed that I spend almost 10% of my time in casbin.util.has_eval.
I believe it could be avoided if we reused the has_eval variable computed out of the loop (line 369). It could also probably be cached in the Assertion object stored in self.model["m"][mtype]
https://github.com/casbin/pycasbin/blob/a16bfaa669c37ac1598684e36b0319430ab749e5/casbin/core_enforcer.py#L369
has_eval = util.has_eval(exp_string)
https://github.com/casbin/pycasbin/blob/a16bfaa669c37ac1598684e36b0319430ab749e5/casbin/core_enforcer.py#L388

Let me know if you would like a PR

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions