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
Optimization of settings atrs to current thread. #32000
Conversation
Hello, Thank you for you patch but it seems you have not signed the CLA. |
Hello As far as I remember we took a quick look at the current_thread() implementation and it was quite light, but I may be wrong about that. import time
import threading
ct = threading.current_thread()
def perfs(func, iter = 10000000):
init = time.time()
for i in range(0, iter):
func()
print('Finished %s in %s s' % (iter, (time.time()-init)))
def current_thread():
return ct
perfs(threading.current_thread)
perfs(current_thread) Results:
I tested with python2.7 and 3.7 and results are similar. I don't mean that your suggestion is wrong but I'd like to understand why you consider that current_thread() is "slow" and if you have an example use case so that we can write a explanatory commit message. |
Function |
reuse current_thread result No needed to call threading.current_thread() on evry arg setting
Thanks for the clarification. It makes no noticable difference for the performance but is a nice code cleaning. @robodoo r+ |
Because this PR has multiple commits, I need to know how to merge it:
|
robodoo rebase-ff |
Merge method set to rebase and fast-forward |
reuse current_thread result No needed to call threading.current_thread() on evry arg setting closes #32000 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Merged, thanks! |
No needed call slow threading.current_thread() on evry arg setting.
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr