Skip to content

Commit

Permalink
gh-112069: Do not require lock if the set has never been exposed.
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Apr 18, 2024
1 parent 94444ea commit 50d62bd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,12 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds)
if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable))
return -1;

if (self->fill == 0 && Py_REFCNT(self) == 1) {
if (iterable == NULL) {
return 0;
}
return set_update_local(self, iterable);
}
Py_BEGIN_CRITICAL_SECTION(self);
if (self->fill)
set_clear_internal(self);
Expand Down

0 comments on commit 50d62bd

Please sign in to comment.