pop & append
gmcm at hypernet.com
Mon Aug 30 18:26:12 CEST 1999
Robin Becker writes:
> Someone from the Zope list tells me that the list pop and append
> operations are thread safe. Is this the case?
Yes, from the perspective of the thread doing the append / pop (*).
> How can one tell if
> particular bits of python code are 'atomic'?
If it happens in one op-code, (how's that for a non-answer :-)).
(*) The fact that the append / pop is thread safe doesn't mean that
it won't screw up another thread which is iterating the list. Such
iterations should always use a copy (list[:], which is also atomic),
or protect the list with a Condition (and iterate as fast as
More information about the Python-list