3 ms·
Python says those insert operations are atomic. https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe https://docs.pyth
by eesmith 3y ago
Python says those insert operations are atomic. https://docs.python.org/3/faq/library.html#what-kinds-of-global-value-mutation-are-thread-safe https://docs.python.org/3/faq/library.html#what-kinds-of-glo...
For example, the following operations are all atomic (L, L1, L2
are lists, D, D1, D2 are dicts, x, y are objects, i, j are ints):
L.append(x)
L1.extend(L2)
x = L[i]
x = L.pop()
L1[i:j] = L2
L.sort()
x = y
x.field = y
D[x] = y
D1.update(D2)
D.keys()
- mikepurvis 3y agoThat's helpful that that's explicitly documented as such then, rather than just a "lol GIL" implementation detail that people have been able to take advantage of since forever— not carrying a documented guarantee like that over into GIL-less python's stdlib would be a nightmare.