Is defaultdict thread safe?

Frank Millman frank at chagford.com
Mon Jan 25 03:59:01 EST 2010


Hi all

Is defaultdict thread safe?

Assume I have -

    from collections import defaultdict
    my_dict = defaultdict(list)

If two threads call "my_dict['abc'].append(...)" simultaneously, is it 
guaranteed that my_dict['abc'] will end up containing two elements?

Thanks

Frank Millman






More information about the Python-list mailing list