From 422fede38eed9667a2200f0aaf4afe9e3ac9d551 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Tue, 9 Nov 2010 01:49:22 +0000 Subject: [PATCH] Replaced PyObject_CallFunction() with *ObjArgs() where more efficient. --- ChangeLog | 4 ++++ psycopg/adapter_asis.c | 2 +- psycopg/adapter_binary.c | 2 +- psycopg/adapter_pboolean.c | 2 +- psycopg/adapter_pdecimal.c | 2 +- psycopg/adapter_pfloat.c | 2 +- psycopg/connection_type.c | 2 +- psycopg/cursor_type.c | 2 +- 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11b6fc90..898b203c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-11-09 Daniele Varrazzo + + * Replaced PyObject_CallFunction() with *ObjArgs() where more efficient. + 2010-11-08 Daniele Varrazzo * psycopg/microprotocols.c: use faster function to build tuples. diff --git a/psycopg/adapter_asis.c b/psycopg/adapter_asis.c index 7d049c2a..4b50e9d0 100644 --- a/psycopg/adapter_asis.c +++ b/psycopg/adapter_asis.c @@ -241,5 +241,5 @@ psyco_AsIs(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; - return PyObject_CallFunction((PyObject *)&asisType, "O", obj); + return PyObject_CallFunctionObjArgs((PyObject *)&asisType, obj, NULL); } diff --git a/psycopg/adapter_binary.c b/psycopg/adapter_binary.c index a1dfba57..641d317a 100644 --- a/psycopg/adapter_binary.c +++ b/psycopg/adapter_binary.c @@ -325,5 +325,5 @@ psyco_Binary(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "O", &str)) return NULL; - return PyObject_CallFunction((PyObject *)&binaryType, "O", str); + return PyObject_CallFunctionObjArgs((PyObject *)&binaryType, str, NULL); } diff --git a/psycopg/adapter_pboolean.c b/psycopg/adapter_pboolean.c index a52cecee..4fd143b7 100644 --- a/psycopg/adapter_pboolean.c +++ b/psycopg/adapter_pboolean.c @@ -254,5 +254,5 @@ psyco_Boolean(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; - return PyObject_CallFunction((PyObject *)&pbooleanType, "O", obj); + return PyObject_CallFunctionObjArgs((PyObject *)&pbooleanType, obj, NULL); } diff --git a/psycopg/adapter_pdecimal.c b/psycopg/adapter_pdecimal.c index c11e7538..e5c039a0 100644 --- a/psycopg/adapter_pdecimal.c +++ b/psycopg/adapter_pdecimal.c @@ -276,5 +276,5 @@ psyco_Decimal(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; - return PyObject_CallFunction((PyObject *)&pdecimalType, "O", obj); + return PyObject_CallFunctionObjArgs((PyObject *)&pdecimalType, obj, NULL); } diff --git a/psycopg/adapter_pfloat.c b/psycopg/adapter_pfloat.c index 7c1fe77b..ccfad740 100644 --- a/psycopg/adapter_pfloat.c +++ b/psycopg/adapter_pfloat.c @@ -246,5 +246,5 @@ psyco_Float(PyObject *module, PyObject *args) if (!PyArg_ParseTuple(args, "O", &obj)) return NULL; - return PyObject_CallFunction((PyObject *)&pfloatType, "O", obj); + return PyObject_CallFunctionObjArgs((PyObject *)&pfloatType, obj, NULL); } diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index bc3aa876..c4d46714 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -91,7 +91,7 @@ psyco_conn_cursor(connectionObject *self, PyObject *args, PyObject *keywds) if (name) obj = PyObject_CallFunction(factory, "Os", self, name); else - obj = PyObject_CallFunction(factory, "O", self); + obj = PyObject_CallFunctionObjArgs(factory, self, NULL); if (obj == NULL) return NULL; if (PyObject_IsInstance(obj, (PyObject *)&cursorType) == 0) { diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index 949433b2..0809ac7d 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -726,7 +726,7 @@ _psyco_curs_buildrow_with_factory(cursorObject *self, int row) PyObject *res; n = PQnfields(self->pgres); - if ((res = PyObject_CallFunction(self->tuple_factory, "O", self))== NULL) + if (!(res = PyObject_CallFunctionObjArgs(self->tuple_factory, self, NULL))) return NULL; return _psyco_curs_buildrow_fill(self, res, row, n, 0);