From f50215412cdc41b7845a6c0bb040a8f3521a0b84 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Thu, 4 Feb 2016 02:46:16 -0800 Subject: [PATCH] Add early-out for the common case where kwds is NULL (gives 1.1% speedup). --- Objects/setobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/setobject.c b/Objects/setobject.c index 8cb3f364c57..c9834a89e2b 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -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);