Python threading module documentation recommends using threading.local()
for storing data that is not to be shared between threads.
Is there any fundamental problem using
threading.current_thread().x= 42
instead of
mydata= threading.local()
mydata.x= 42
?
The former pollutes the namespace of the thread object a little, but that can be handled if needed. Other than that, both approaches seem to work, but there must be a reason why the latter is recommended in the docs.