diff options
author | Georg Brandl <georg@python.org> | 2006-05-25 19:15:31 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-05-25 19:15:31 (GMT) |
commit | 684fd0c8ec0bad54d3ff39ae15873f80e119478b (patch) | |
tree | 56596aed7bfd401ebe049e566201f75f88150b27 | |
parent | 3b0cae9cc06374eb7a7159f1328ec700208d6109 (diff) | |
download | cpython-684fd0c8ec0bad54d3ff39ae15873f80e119478b.zip cpython-684fd0c8ec0bad54d3ff39ae15873f80e119478b.tar.gz cpython-684fd0c8ec0bad54d3ff39ae15873f80e119478b.tar.bz2 |
Replace PyObject_CallFunction calls with only object args
with PyObject_CallFunctionObjArgs, which is 30% faster.
-rw-r--r-- | Modules/cPickle.c | 4 | ||||
-rw-r--r-- | Modules/gcmodule.c | 2 | ||||
-rw-r--r-- | Modules/parsermodule.c | 4 | ||||
-rw-r--r-- | Objects/classobject.c | 7 | ||||
-rw-r--r-- | Objects/typeobject.c | 10 | ||||
-rw-r--r-- | Objects/weakrefobject.c | 2 | ||||
-rw-r--r-- | Python/ceval.c | 2 | ||||
-rw-r--r-- | Python/import.c | 6 |
8 files changed, 17 insertions, 20 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c index 9948ba7..4c630bb 100644 --- a/Modules/cPickle.c +++ b/Modules/cPickle.c @@ -3073,8 +3073,8 @@ find_class(PyObject *py_module_name, PyObject *py_global_name, PyObject *fc) "pickles are not supported."); return NULL; } - return PyObject_CallFunction(fc, "OO", py_module_name, - py_global_name); + return PyObject_CallFunctionObjArgs(fc, py_module_name, + py_global_name, NULL); } module = PySys_GetObject("modules"); diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 6ff2c9a..872727d 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -603,7 +603,7 @@ handle_weakrefs(PyGC_Head *unreachable, PyGC_Head *old) assert(callback != NULL); /* copy-paste of weakrefobject.c's handle_callback() */ - temp = PyObject_CallFunction(callback, "O", wr); + temp = PyObject_CallFunctionObjArgs(callback, wr, NULL); if (temp == NULL) PyErr_WriteUnraisable(callback); else diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index c9edae6..e33197e 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -3267,8 +3267,8 @@ initparser(void) && (pickler != NULL)) { PyObject *res; - res = PyObject_CallFunction(func, "OOO", &PyST_Type, pickler, - pickle_constructor); + res = PyObject_CallFunctionObjArgs(func, &PyST_Type, pickler, + pickle_constructor, NULL); Py_XDECREF(res); } Py_XDECREF(func); diff --git a/Objects/classobject.c b/Objects/classobject.c index a1907f5..a89366b 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -81,12 +81,9 @@ PyClass_New(PyObject *bases, PyObject *dict, PyObject *name) if (!PyClass_Check(base)) { if (PyCallable_Check( (PyObject *) base->ob_type)) - return PyObject_CallFunction( + return PyObject_CallFunctionObjArgs( (PyObject *) base->ob_type, - "OOO", - name, - bases, - dict); + name, bases, dict, NULL); PyErr_SetString(PyExc_TypeError, "PyClass_New: base must be a class"); return NULL; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0905d19..0881ab1 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4641,10 +4641,10 @@ slot_tp_getattr_hook(PyObject *self, PyObject *name) (void *)PyObject_GenericGetAttr)) res = PyObject_GenericGetAttr(self, name); else - res = PyObject_CallFunction(getattribute, "OO", self, name); + res = PyObject_CallFunctionObjArgs(getattribute, self, name, NULL); if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); - res = PyObject_CallFunction(getattr, "OO", self, name); + res = PyObject_CallFunctionObjArgs(getattr, self, name, NULL); } return res; } @@ -4781,7 +4781,7 @@ slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type) obj = Py_None; if (type == NULL) type = Py_None; - return PyObject_CallFunction(get, "OOO", self, obj, type); + return PyObject_CallFunctionObjArgs(get, self, obj, type, NULL); } static int @@ -5728,8 +5728,8 @@ super_descr_get(PyObject *self, PyObject *obj, PyObject *type) if (su->ob_type != &PySuper_Type) /* If su is an instance of a (strict) subclass of super, call its type */ - return PyObject_CallFunction((PyObject *)su->ob_type, - "OO", su->type, obj); + return PyObject_CallFunctionObjArgs((PyObject *)su->ob_type, + su->type, obj, NULL); else { /* Inline the common case */ PyTypeObject *obj_type = supercheck(su->type, obj); diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index a8ab56e..bbeb3c0 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -851,7 +851,7 @@ PyWeakref_GetObject(PyObject *ref) static void handle_callback(PyWeakReference *ref, PyObject *callback) { - PyObject *cbresult = PyObject_CallFunction(callback, "O", ref); + PyObject *cbresult = PyObject_CallFunctionObjArgs(callback, ref, NULL); if (cbresult == NULL) PyErr_WriteUnraisable(callback); diff --git a/Python/ceval.c b/Python/ceval.c index b59f718..3043f82 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4053,7 +4053,7 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name) metaclass = (PyObject *) &PyClass_Type; Py_INCREF(metaclass); } - result = PyObject_CallFunction(metaclass, "OOO", name, bases, methods); + result = PyObject_CallFunctionObjArgs(metaclass, name, bases, methods, NULL); Py_DECREF(metaclass); if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError)) { /* A type error here likely means that the user passed diff --git a/Python/import.c b/Python/import.c index 6642082..862f33c 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1043,7 +1043,7 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = PyObject_CallFunction(hook, "O", p); + importer = PyObject_CallFunctionObjArgs(hook, p, NULL); if (importer != NULL) break; @@ -2499,8 +2499,8 @@ PyImport_Import(PyObject *module_name) goto err; /* Call the _import__ function with the proper argument list */ - r = PyObject_CallFunction(import, "OOOO", - module_name, globals, globals, silly_list); + r = PyObject_CallFunctionObjArgs(import, module_name, globals, + globals, silly_list, NULL); err: Py_XDECREF(globals); |