diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-12-01 13:43:22 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-12-01 13:43:22 (GMT) |
commit | 27580c1fb5e8cb756304f523006d832d2e3532e7 (patch) | |
tree | f25f5c8e7a05f3d3d4049050459fecd7e81a5b46 /Modules/_json.c | |
parent | 8be1c39eb3416e9d85c7e3ccd4794969588c8030 (diff) | |
download | cpython-27580c1fb5e8cb756304f523006d832d2e3532e7.zip cpython-27580c1fb5e8cb756304f523006d832d2e3532e7.tar.gz cpython-27580c1fb5e8cb756304f523006d832d2e3532e7.tar.bz2 |
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.
Diffstat (limited to 'Modules/_json.c')
-rw-r--r-- | Modules/_json.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/_json.c b/Modules/_json.c index d3dbf98..da7b2ed 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; |