[docs] [issue25343] Document atomic operations on builtin types

Raymond Hettinger report at bugs.python.org
Fri Oct 9 02:37:35 CEST 2015


Raymond Hettinger added the comment:

> what set() operations are atomic?

The language doesn't make any guarantees about set operation atomicity.  Different implementations such as PyPy, Jython, and IronPython are free to make different choices than CPython.  In general, users should make no assumptions about atomicity unless explicitly documented and tested.  The wise course of action is to use mutexes when there is any doubt.

FWIW, it is difficult to make blanket statements about the methods on sets because the atomicity depends on the objects looked up or stored in the sets rather than the set itself.   Aside from trivial calls to __sizeof__ and __len__, most set methods potentially call __hash__ or __eq__ on the set elements either of which could make a callback into pure python code.  Likewise, any reference count decrement can potentially make a callback as well.

----------
nosy: +rhettinger

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25343>
_______________________________________


More information about the docs mailing list