From 27580c1fb5e8cb756304f523006d832d2e3532e7 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 1 Dec 2016 14:43:22 +0100 Subject: Replace PyObject_CallFunctionObjArgs() with fastcall * PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507. --- Modules/_json.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Modules/_json.c') diff --git a/Modules/_json.c b/Modules/_json.c index d3dbf98805..da7b2edeaa 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -813,14 +813,14 @@ _parse_object_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ss *next_idx_ptr = idx + 1; if (has_pairs_hook) { - val = PyObject_CallFunctionObjArgs(s->object_pairs_hook, rval, NULL); + val = _PyObject_CallArg1(s->object_pairs_hook, rval); Py_DECREF(rval); return val; } /* if object_hook is not None: rval = object_hook(rval) */ if (s->object_hook != Py_None) { - val = PyObject_CallFunctionObjArgs(s->object_hook, rval, NULL); + val = _PyObject_CallArg1(s->object_hook, rval); Py_DECREF(rval); return val; } @@ -924,7 +924,7 @@ _parse_constant(PyScannerObject *s, const char *constant, Py_ssize_t idx, Py_ssi return NULL; /* rval = parse_constant(constant) */ - rval = PyObject_CallFunctionObjArgs(s->parse_constant, cstr, NULL); + rval = _PyObject_CallArg1(s->parse_constant, cstr); idx += PyUnicode_GET_LENGTH(cstr); Py_DECREF(cstr); *next_idx_ptr = idx; @@ -1023,7 +1023,7 @@ _match_number_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ idx - start); if (numstr == NULL) return NULL; - rval = PyObject_CallFunctionObjArgs(custom_func, numstr, NULL); + rval = _PyObject_CallArg1(custom_func, numstr); } else { Py_ssize_t i, n; @@ -1475,7 +1475,7 @@ encoder_encode_string(PyEncoderObject *s, PyObject *obj) if (s->fast_encode) return s->fast_encode(NULL, obj); else - return PyObject_CallFunctionObjArgs(s->encoder, obj, NULL); + return _PyObject_CallArg1(s->encoder, obj); } static int @@ -1553,7 +1553,7 @@ encoder_listencode_obj(PyEncoderObject *s, _PyAccu *acc, return -1; } } - newobj = PyObject_CallFunctionObjArgs(s->defaultfn, obj, NULL); + newobj = _PyObject_CallArg1(s->defaultfn, obj); if (newobj == NULL) { Py_XDECREF(ident); return -1; -- cgit v1.2.1