Simplify and speedup uses of Py_BuildValue():

* Py_BuildValue("(OOO)",a,b,c)  -->  PyTuple_Pack(3,a,b,c)
* Py_BuildValue("()",a)         -->  PyTuple_New(0)
* Py_BuildValue("O", a)         -->  Py_INCREF(a)
This commit is contained in:
Raymond Hettinger 2003-10-12 19:09:37 +00:00
parent cb2da43db8
commit 8ae4689657
25 changed files with 71 additions and 75 deletions

View file

@ -439,7 +439,7 @@ complex_divmod(PyComplexObject *v, PyComplexObject *w)
mod = c_diff(v->cval, c_prod(w->cval, div));
d = PyComplex_FromCComplex(div);
m = PyComplex_FromCComplex(mod);
z = Py_BuildValue("(OO)", d, m);
z = PyTuple_Pack(2, d, m);
Py_XDECREF(d);
Py_XDECREF(m);
return z;
@ -865,7 +865,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (f == NULL)
PyErr_Clear();
else {
PyObject *args = Py_BuildValue("()");
PyObject *args = PyTuple_New(0);
if (args == NULL)
return NULL;
r = PyEval_CallObject(f, args);