Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d1ff00

Browse files
committed
Mini-optimization: use pack/unpack functions for argument tuples.
1 parent 0f63257 commit 5d1ff00

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Python/bltinmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
112112
ns = PyDict_New();
113113
}
114114
else {
115-
PyObject *pargs = Py_BuildValue("OO", name, bases);
115+
PyObject *pargs = PyTuple_Pack(2, name, bases);
116116
if (pargs == NULL) {
117117
Py_DECREF(prep);
118118
Py_DECREF(meta);
@@ -133,7 +133,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
133133
cell = PyObject_CallFunctionObjArgs(func, ns, NULL);
134134
if (cell != NULL) {
135135
PyObject *margs;
136-
margs = Py_BuildValue("OOO", name, bases, ns);
136+
margs = PyTuple_Pack(3, name, bases, ns);
137137
if (margs != NULL) {
138138
cls = PyEval_CallObjectWithKeywords(meta, margs, mkw);
139139
Py_DECREF(margs);
@@ -754,7 +754,7 @@ builtin_exec(PyObject *self, PyObject *args)
754754
PyObject *prog, *globals = Py_None, *locals = Py_None;
755755
int plain = 0;
756756

757-
if (!PyArg_ParseTuple(args, "O|OO:exec", &prog, &globals, &locals))
757+
if (!PyArg_UnpackTuple(args, "exec", 1, 3, &prog, &globals, &locals))
758758
return NULL;
759759

760760
if (globals == Py_None) {

0 commit comments

Comments
 (0)