]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Speed-up construction of empty sets by approx 12-14%.
authorRaymond Hettinger <python@rcn.com>
Fri, 25 Mar 2016 09:29:59 +0000 (02:29 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 25 Mar 2016 09:29:59 +0000 (02:29 -0700)
Objects/setobject.c

index c9834a89e2b39744ee45b3da4a0c771d008505e1..8e22b690206ee84eb586f8ec3f2327dd85aaa873 100644 (file)
@@ -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;