Commit 5d1ff00b authored by Raymond Hettinger's avatar Raymond Hettinger

Mini-optimization: use pack/unpack functions for argument tuples.

parent 0f632571
...@@ -112,7 +112,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -112,7 +112,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
ns = PyDict_New(); ns = PyDict_New();
} }
else { else {
PyObject *pargs = Py_BuildValue("OO", name, bases); PyObject *pargs = PyTuple_Pack(2, name, bases);
if (pargs == NULL) { if (pargs == NULL) {
Py_DECREF(prep); Py_DECREF(prep);
Py_DECREF(meta); Py_DECREF(meta);
...@@ -133,7 +133,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -133,7 +133,7 @@ builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
cell = PyObject_CallFunctionObjArgs(func, ns, NULL); cell = PyObject_CallFunctionObjArgs(func, ns, NULL);
if (cell != NULL) { if (cell != NULL) {
PyObject *margs; PyObject *margs;
margs = Py_BuildValue("OOO", name, bases, ns); margs = PyTuple_Pack(3, name, bases, ns);
if (margs != NULL) { if (margs != NULL) {
cls = PyEval_CallObjectWithKeywords(meta, margs, mkw); cls = PyEval_CallObjectWithKeywords(meta, margs, mkw);
Py_DECREF(margs); Py_DECREF(margs);
...@@ -754,7 +754,7 @@ builtin_exec(PyObject *self, PyObject *args) ...@@ -754,7 +754,7 @@ builtin_exec(PyObject *self, PyObject *args)
PyObject *prog, *globals = Py_None, *locals = Py_None; PyObject *prog, *globals = Py_None, *locals = Py_None;
int plain = 0; int plain = 0;
if (!PyArg_ParseTuple(args, "O|OO:exec", &prog, &globals, &locals)) if (!PyArg_UnpackTuple(args, "exec", 1, 3, &prog, &globals, &locals))
return NULL; return NULL;
if (globals == Py_None) { if (globals == Py_None) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment