From: Raymond Hettinger Date: Fri, 25 Mar 2016 09:29:59 +0000 (-0700) Subject: Speed-up construction of empty sets by approx 12-14%. X-Git-Tag: v3.6.0a1~335 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b72e21b9ab8021b7cbb7e0007d1bf80d533bce15;p=thirdparty%2FPython%2Fcpython.git Speed-up construction of empty sets by approx 12-14%. --- diff --git a/Objects/setobject.c b/Objects/setobject.c index c9834a89e2b3..8e22b690206e 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;