summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-19 16:59:15 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-19 16:59:15 (GMT)
commit75210697ecb830b592bcb5d22503ddbb8401f3e8 (patch)
treeaab8e6ebea2cc3369b7d2a884721a2be00e33000 /Modules/_pickle.c
parentf7a4c488b55e5f7ce9bdb85d050179ba91008b70 (diff)
downloadcpython-75210697ecb830b592bcb5d22503ddbb8401f3e8.zip
cpython-75210697ecb830b592bcb5d22503ddbb8401f3e8.tar.gz
cpython-75210697ecb830b592bcb5d22503ddbb8401f3e8.tar.bz2
Issue #27128: _pickle uses fast call
Use _PyObject_FastCall() to avoid the creation of temporary tuple.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index ddac243..b454134 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -345,7 +345,6 @@ static PyObject *
_Pickle_FastCall(PyObject *func, PyObject *obj)
{
PyObject *result;
- PyObject *arg_tuple = PyTuple_New(1);
/* Note: this function used to reuse the argument tuple. This used to give
a slight performance boost with older pickle implementations where many
@@ -358,13 +357,8 @@ _Pickle_FastCall(PyObject *func, PyObject *obj)
significantly reduced the number of function calls we do. Thus, the
benefits became marginal at best. */
- if (arg_tuple == NULL) {
- Py_DECREF(obj);
- return NULL;
- }
- PyTuple_SET_ITEM(arg_tuple, 0, obj);
- result = PyObject_Call(func, arg_tuple, NULL);
- Py_CLEAR(arg_tuple);
+ result = _PyObject_FastCall(func, &obj, 1, NULL);
+ Py_DECREF(obj);
return result;
}
@@ -1157,9 +1151,7 @@ _Unpickler_ReadFromFile(UnpicklerObject *self, Py_ssize_t n)
return -1;
if (n == READ_WHOLE_LINE) {
- PyObject *empty_tuple = PyTuple_New(0);
- data = PyObject_Call(self->readline, empty_tuple, NULL);
- Py_DECREF(empty_tuple);
+ data = _PyObject_FastCall(self->readline, NULL, 0, NULL);
}
else {
PyObject *len;
@@ -3956,10 +3948,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
/* Check for a __reduce__ method. */
reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__);
if (reduce_func != NULL) {
- PyObject *empty_tuple = PyTuple_New(0);
- reduce_value = PyObject_Call(reduce_func, empty_tuple,
- NULL);
- Py_DECREF(empty_tuple);
+ reduce_value = _PyObject_FastCall(reduce_func, NULL, 0, NULL);
}
else {
PyErr_Format(st->PicklingError,