We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d1aaf9a commit 37ac4ceCopy full SHA for 37ac4ce
Objects/setobject.c
@@ -2774,9 +2774,9 @@ int
2774
PySet_Add(PyObject *anyset, PyObject *key)
2775
{
2776
if (_PyObject_IsUniquelyReferenced(anyset) && PyAnySet_Check(anyset)) {
2777
- // In free-threading, if the set or frozenset is uniquely referenced,
2778
- // no critical section is needed since only the owner thread is
2779
- // populating it.
+ // We can only change frozensets if they are uniquely referenced,
+ // and we can avoid locking sets even in free-threaded build if they
+ // are uniquely referenced.
2780
return set_add_key((PySetObject *)anyset, key);
2781
}
2782
0 commit comments