From 366f4ee4da4420842eac26b3fa00c2b01d4515a6 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/_ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/_ssl.c') diff --git a/Modules/_ssl.c b/Modules/_ssl.c index b198857060..6003476052 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3197,7 +3197,7 @@ _password_callback(char *buf, int size, int rwflag, void *userdata) PySSL_END_ALLOW_THREADS_S(pw_info->thread_state); if (pw_info->callable) { - fn_ret = PyObject_CallFunctionObjArgs(pw_info->callable, NULL); + fn_ret = _PyObject_CallNoArg(pw_info->callable); if (!fn_ret) { /* TODO: It would be nice to move _ctypes_add_traceback() into the core python API, so we could use it to add a frame here */ -- cgit v1.2.1 From 39ae5bedd90f9caf9a78efa82f4d11e838933b3a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 4 Dec 2016 22:59:09 +0100 Subject: Backed out changeset b9c9691c72c5 Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs(). --- Modules/_ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/_ssl.c') diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 6003476052..b198857060 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3197,7 +3197,7 @@ _password_callback(char *buf, int size, int rwflag, void *userdata) PySSL_END_ALLOW_THREADS_S(pw_info->thread_state); if (pw_info->callable) { - fn_ret = _PyObject_CallNoArg(pw_info->callable); + fn_ret = PyObject_CallFunctionObjArgs(pw_info->callable, NULL); if (!fn_ret) { /* TODO: It would be nice to move _ctypes_add_traceback() into the core python API, so we could use it to add a frame here */ -- cgit v1.2.1 From a95a307d2cbb7fc1c778691f142e0c21c05fd5bc Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 6 Dec 2016 18:46:19 +0100 Subject: Use _PyObject_CallNoArg() Replace: PyObject_CallFunctionObjArgs(callable, NULL) with: _PyObject_CallNoArg(callable) --- Modules/_ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Modules/_ssl.c') diff --git a/Modules/_ssl.c b/Modules/_ssl.c index b198857060..6003476052 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -3197,7 +3197,7 @@ _password_callback(char *buf, int size, int rwflag, void *userdata) PySSL_END_ALLOW_THREADS_S(pw_info->thread_state); if (pw_info->callable) { - fn_ret = PyObject_CallFunctionObjArgs(pw_info->callable, NULL); + fn_ret = _PyObject_CallNoArg(pw_info->callable); if (!fn_ret) { /* TODO: It would be nice to move _ctypes_add_traceback() into the core python API, so we could use it to add a frame here */ -- cgit v1.2.1 From bfeec6d871e3db2e0ddfdef01387913bc19cadd4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 23 Jan 2017 09:47:21 +0200 Subject: Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever possible. Patch is writen with Coccinelle. --- Modules/_ssl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Modules/_ssl.c') diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 6003476052..1e9a707648 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -755,8 +755,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self) PySSL_END_ALLOW_THREADS self->handshake_done = 1; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; error: Py_XDECREF(sock); @@ -4500,8 +4499,7 @@ _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy) buf += written; len -= written; } while (len); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * -- cgit v1.2.1