@@ -89,6 +89,11 @@ the constructor functions work with any iterable Python object.
8989 actually iterable. The constructor is also useful for copying a set
9090 (``c=set(s) ``).
9191
92+ .. note::
93+
94+ The operation is atomic on :term:`free threading <free-threaded build>`
95+ when *iterable* is a :class:`set`, :class:`frozenset`, :class:`dict` or :class:`frozendict`.
96+
9297
9398.. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable)
9499
@@ -97,6 +102,11 @@ the constructor functions work with any iterable Python object.
97102 set on success or ``NULL `` on failure. Raise :exc: `TypeError ` if *iterable * is
98103 not actually iterable.
99104
105+ .. note ::
106+
107+ The operation is atomic on :term: `free threading <free-threaded build> `
108+ when *iterable * is a :class: `set `, :class: `frozenset `, :class: `dict ` or :class: `frozendict `.
109+
100110
101111The following functions and macros are available for instances of :class: `set `
102112or :class: `frozenset ` or instances of their subtypes.
@@ -124,6 +134,10 @@ or :class:`frozenset` or instances of their subtypes.
124134 the *key * is unhashable. Raise :exc: `SystemError ` if *anyset * is not a
125135 :class: `set `, :class: `frozenset `, or an instance of a subtype.
126136
137+ .. note ::
138+
139+ The operation is atomic on :term: `free threading <free-threaded build> `
140+ when *key * is :class: `str `, :class: `int `, :class: `float `, :class: `bool ` or :class: `bytes `.
127141
128142.. c :function :: int PySet_Add (PyObject *set, PyObject *key)
129143
@@ -135,6 +149,12 @@ or :class:`frozenset` or instances of their subtypes.
135149 :exc:`SystemError` if *set* is not an instance of :class:`set` or its
136150 subtype.
137151
152+ .. note::
153+
154+ The operation is atomic on :term:`free threading <free-threaded build>`
155+ when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
156+
157+
138158
139159The following functions are available for instances of :class:`set` or its
140160subtypes but not for instances of :class:`frozenset` or its subtypes.
@@ -149,6 +169,11 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
149169 temporary frozensets. Raise :exc:`SystemError` if *set* is not an
150170 instance of :class:`set` or its subtype.
151171
172+ .. note::
173+
174+ The operation is atomic on :term:`free threading <free-threaded build>`
175+ when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
176+
152177
153178.. c:function:: PyObject* PySet_Pop(PyObject *set)
154179
@@ -164,6 +189,12 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
164189 success. Return ``-1 `` and raise :exc: `SystemError ` if *set * is not an instance of
165190 :class: `set ` or its subtype.
166191
192+ .. note ::
193+
194+ In the :term: `free-threaded build `, the set is emptied before its entries
195+ are cleared, so other threads will observe an empty set rather than
196+ intermediate states.
197+
167198
168199Deprecated API
169200^^^^^^^^^^^^^^
0 commit comments