This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients Dima.Tisnek, brett.cannon, docs@python, r.david.murray, rhettinger
Date 2015-10-09.00:37:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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.
Date User Action Args
2015-10-09 00:37:35rhettingersetrecipients: + rhettinger, brett.cannon, r.david.murray, docs@python, Dima.Tisnek
2015-10-09 00:37:34rhettingersetmessageid: <>
2015-10-09 00:37:34rhettingerlinkissue25343 messages
2015-10-09 00:37:33rhettingercreate