@@ -92,6 +92,11 @@ the constructor functions work with any iterable Python object.
9292 actually iterable. The constructor is also useful for copying a set
9393 (``c=set(s) ``).
9494
95+ .. note::
96+
97+ The operation is atomic on :term:`free threading <free-threaded build>`
98+ when *iterable* is a :class:`set`, :class:`frozenset`, :class:`dict` or :class:`frozendict`.
99+
95100
96101.. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable)
97102
@@ -100,6 +105,11 @@ the constructor functions work with any iterable Python object.
100105 set on success or ``NULL `` on failure. Raise :exc: `TypeError ` if *iterable * is
101106 not actually iterable.
102107
108+ .. note ::
109+
110+ The operation is atomic on :term: `free threading <free-threaded build> `
111+ when *iterable * is a :class: `set `, :class: `frozenset `, :class: `dict ` or :class: `frozendict `.
112+
103113
104114The following functions and macros are available for instances of :class: `set `
105115or :class: `frozenset ` or instances of their subtypes.
@@ -127,6 +137,10 @@ or :class:`frozenset` or instances of their subtypes.
127137 the *key * is unhashable. Raise :exc: `SystemError ` if *anyset * is not a
128138 :class: `set `, :class: `frozenset `, or an instance of a subtype.
129139
140+ .. note ::
141+
142+ The operation is atomic on :term: `free threading <free-threaded build> `
143+ when *key * is :class: `str `, :class: `int `, :class: `float `, :class: `bool ` or :class: `bytes `.
130144
131145.. c :function :: int PySet_Add (PyObject *set, PyObject *key)
132146
@@ -138,6 +152,12 @@ or :class:`frozenset` or instances of their subtypes.
138152 :exc:`SystemError` if *set* is not an instance of :class:`set` or its
139153 subtype.
140154
155+ .. note::
156+
157+ The operation is atomic on :term:`free threading <free-threaded build>`
158+ when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
159+
160+
141161
142162The following functions are available for instances of :class:`set` or its
143163subtypes but not for instances of :class:`frozenset` or its subtypes.
@@ -152,6 +172,11 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
152172 temporary frozensets. Raise :exc:`SystemError` if *set* is not an
153173 instance of :class:`set` or its subtype.
154174
175+ .. note::
176+
177+ The operation is atomic on :term:`free threading <free-threaded build>`
178+ when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
179+
155180
156181.. c:function:: PyObject* PySet_Pop(PyObject *set)
157182
@@ -167,6 +192,12 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
167192 success. Return ``-1 `` and raise :exc: `SystemError ` if *set * is not an instance of
168193 :class: `set ` or its subtype.
169194
195+ .. note ::
196+
197+ In the :term: `free-threaded build `, the set is emptied before its entries
198+ are cleared, so other threads will observe an empty set rather than
199+ intermediate states.
200+
170201
171202Deprecated API
172203^^^^^^^^^^^^^^
0 commit comments