Skip to content

Commit 50d62bd

Browse files
committed
gh-112069: Do not require lock if the set has never been exposed.
1 parent 94444ea commit 50d62bd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: Objects/setobject.c

+6
Original file line numberDiff line numberDiff line change
@@ -2334,6 +2334,12 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
23342334
if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
23352335
return -1;
23362336

2337+
if (self->fill == 0 && Py_REFCNT(self) == 1) {
2338+
if (iterable == NULL) {
2339+
return 0;
2340+
}
2341+
return set_update_local(self, iterable);
2342+
}
23372343
Py_BEGIN_CRITICAL_SECTION(self);
23382344
if (self->fill)
23392345
set_clear_internal(self);

0 commit comments

Comments
 (0)