diff options
author | Donghee Na <donghee.na@python.org> | 2024-04-25 15:13:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 15:13:57 (GMT) |
commit | eb20a7d12c4b2ab7931074843f8602a48b5b07bd (patch) | |
tree | 67aa7a3fc8eb52c27b158a6cc767b807df040023 /Objects | |
parent | 1723c76d794bef23b518bc79d83281c7309d4832 (diff) | |
download | cpython-eb20a7d12c4b2ab7931074843f8602a48b5b07bd.zip cpython-eb20a7d12c4b2ab7931074843f8602a48b5b07bd.tar.gz cpython-eb20a7d12c4b2ab7931074843f8602a48b5b07bd.tar.bz2 |
gh-112069: Do not require lock if the set has never been exposed. (gh-118069)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/setobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 0d88f4f..19975e3 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2333,6 +2333,13 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds) if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable)) return -1; + if (Py_REFCNT(self) == 1 && self->fill == 0) { + self->hash = -1; + if (iterable == NULL) { + return 0; + } + return set_update_local(self, iterable); + } Py_BEGIN_CRITICAL_SECTION(self); if (self->fill) set_clear_internal(self); |