mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
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:
parent
cb2da43db8
commit
8ae4689657
25 changed files with 71 additions and 75 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue