return make_new_set(type, NULL);
}
+#ifdef Py_GIL_DISABLED
+static void
+copy_small_table(setentry *dest, setentry *src)
+{
+ for (Py_ssize_t i = 0; i < PySet_MINSIZE; i++) {
+ _Py_atomic_store_ptr_release(&dest[i].key, src[i].key);
+ _Py_atomic_store_ssize_relaxed(&dest[i].hash, src[i].hash);
+ }
+}
+#endif
+
/* set_swap_bodies() switches the contents of any two sets by moving their
internal data pointers and, if needed, copying the internal smalltables.
Semantically equivalent to:
if (a_table == a->smalltable || b_table == b->smalltable) {
memcpy(tab, a->smalltable, sizeof(tab));
+#ifndef Py_GIL_DISABLED
memcpy(a->smalltable, b->smalltable, sizeof(tab));
memcpy(b->smalltable, tab, sizeof(tab));
+#else
+ copy_small_table(a->smalltable, b->smalltable);
+ copy_small_table(b->smalltable, tab);
+#endif
}
if (PyType_IsSubtype(Py_TYPE(a), &PyFrozenSet_Type) &&