]> granicus.if.org Git - python/commitdiff
Add early-out for the common case where kwds is NULL (gives 1.1% speedup).
authorRaymond Hettinger <python@rcn.com>
Thu, 4 Feb 2016 10:46:16 +0000 (02:46 -0800)
committerRaymond Hettinger <python@rcn.com>
Thu, 4 Feb 2016 10:46:16 +0000 (02:46 -0800)
Objects/setobject.c

index 8cb3f364c577b187f15b398d2c7daaac5e7bb5a2..c9834a89e2b39744ee45b3da4a0c771d008505e1 100644 (file)
@@ -1088,7 +1088,8 @@ frozenset_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     PyObject *iterable = NULL, *result;
 
-    if (type == &PyFrozenSet_Type && !_PyArg_NoKeywords("frozenset()", kwds))
+    if (kwds != NULL && type == &PyFrozenSet_Type
+        && !_PyArg_NoKeywords("frozenset()", kwds))
         return NULL;
 
     if (!PyArg_UnpackTuple(args, type->tp_name, 0, 1, &iterable))
@@ -1130,7 +1131,7 @@ PySet_Fini(void)
 static PyObject *
 set_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    if (type == &PySet_Type && !_PyArg_NoKeywords("set()", kwds))
+    if (kwds != NULL && type == &PySet_Type && !_PyArg_NoKeywords("set()", kwds))
         return NULL;
 
     return make_new_set(type, NULL);