Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
etienne-lebrun opened this issue Jan 12, 2022 · 3 comments
Closed

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

etienne-lebrun opened this issue Jan 12, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request released

Comments

@etienne-lebrun
Copy link
Contributor

etienne-lebrun commented Jan 12, 2022

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]

has_eval = util.has_eval(exp_string)

has_eval = util.has_eval(exp_string)
if util.has_eval(exp_string):

Let me know if you would like a PR

@casbin-bot
Copy link
Member

@ffyuanda @Zxilly @techoner @elfisworking

@casbin-bot casbin-bot added the question Further information is requested label Jan 12, 2022
@leeqvip
Copy link
Member

leeqvip commented Jan 13, 2022

@etienne-lebrun It should reuse has_eval, can you make PR ?

@leeqvip leeqvip added enhancement New feature or request and removed question Further information is requested labels Jan 13, 2022
etienne-lebrun added a commit to etienne-lebrun/pycasbin that referenced this issue Jan 13, 2022
etienne-lebrun added a commit to etienne-lebrun/pycasbin that referenced this issue Jan 13, 2022
etienne-lebrun added a commit to etienne-lebrun/pycasbin that referenced this issue Jan 13, 2022
github-actions bot pushed a commit that referenced this issue Jan 13, 2022
## [1.15.4](v1.15.3...v1.15.4) (2022-01-13)

### Bug Fixes

* [#238](#238), avoid calling has_eval in enforcing loop ([#240](#240)) ([8188b27](8188b27))
@github-actions
Copy link

🎉 This issue has been resolved in version 1.15.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

No branches or pull requests

4 participants