summaryrefslogtreecommitdiff
path: root/Objects/iterobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-16 17:01:09 +0000
committerGuido van Rossum <guido@python.org>2002-08-16 17:01:09 +0000
commit39db7ab3dfa619a920c713621d8cface89610aa6 (patch)
treece2c794f1b87433ebb07fa1c93c4453bdc69d685 /Objects/iterobject.c
parent243bd7b8c4812843f88b13cf5bc8f7d1df3f873c (diff)
downloadcpython-39db7ab3dfa619a920c713621d8cface89610aa6.tar.gz
Squash a few calls to the hideously expensive PyObject_CallObject(o,a)
-- replace then with slightly faster PyObject_Call(o,a,NULL). (The difference is that the latter requires a to be a tuple; the former allows other values and wraps them in a tuple if necessary; it involves two more levels of C function calls to accomplish all that.)
Diffstat (limited to 'Objects/iterobject.c')
-rw-r--r--Objects/iterobject.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index 4dc225a521..2e1caae543 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -163,7 +163,12 @@ static PyObject *
calliter_iternext(calliterobject *it)
{
if (it->it_callable != NULL) {
- PyObject *result = PyObject_CallObject(it->it_callable, NULL);
+ PyObject *args = PyTuple_New(0);
+ PyObject *result;
+ if (args == NULL)
+ return NULL;
+ result = PyObject_Call(it->it_callable, args, NULL);
+ Py_DECREF(args);
if (result != NULL) {
int ok;
ok = PyObject_RichCompareBool(result,