Join GitHub today
Optimization of settings atrs to current thread. #32000
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)
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.