Is collections.defaultdict thread-safe?
问题 I have not worked with threading in Python at all and asking this question as a complete stranger. I am wondering if defaultdict is thread-safe. Let me explain it: I have d = defaultdict(list) which creates a list for missing keys by default. Let's say I have multiple threads started doing this at the same time: d['key'].append('value') At the end, I'm supposed to end up with ['value', 'value'] . However, if the defaultdict is not thread-safe, if the thread 1 yields to thread 2 after checking