diff options
author | Raymond Hettinger <python@rcn.com> | 2016-03-25 02:29:59 -0700 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-03-25 02:29:59 -0700 |
commit | e5f7a04d53414b6511a131854f0830bf7170395b (patch) | |
tree | 4e09a03b6e68db59901a759983ddd9900680a7b5 | |
parent | ae6e7f8746bd1c59bcd4e057deca577a93686692 (diff) | |
download | cpython-e5f7a04d53414b6511a131854f0830bf7170395b.tar.gz |
Speed-up construction of empty sets by approx 12-14%.
-rw-r--r-- | Objects/setobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index c9834a89e2..8e22b69020 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2015,11 +2015,12 @@ set_init(PySetObject *self, PyObject *args, PyObject *kwds) if (!PyAnySet_Check(self)) return -1; - if (PySet_Check(self) && !_PyArg_NoKeywords("set()", kwds)) + if (kwds != NULL && PySet_Check(self) && !_PyArg_NoKeywords("set()", kwds)) return -1; if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable)) return -1; - set_clear_internal(self); + if (self->fill) + set_clear_internal(self); self->hash = -1; if (iterable == NULL) return 0; |