Is Python’s `list.clear()` thread-safe?
In Python, suppose one thread is appending/popping items to/from a list
/collections.deque
/similar built-in container, while another thread occasionally empties the container via its clear()
method. Is this interaction thread-safe? Or is it possible for the clear()
to interfere with a concurrent append()
/pop()
operation, leaving the list uncleared or corrupted?