From 5d858465b6ebdafa05f86309457848cc26913b6a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 20 Nov 2016 10:16:47 +0200 Subject: Added the const qualifier to char* variables that refer to readonly internal UTF-8 represenatation of Unicode objects. --- Python/import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index cd865a5423..6bcb1d79fd 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1035,7 +1035,7 @@ _imp_create_builtin(PyObject *module, PyObject *spec) { struct _inittab *p; PyObject *name; - char *namestr; + const char *namestr; PyObject *mod; name = PyObject_GetAttrString(spec, "name"); -- cgit v1.2.1 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. --- Python/import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index 6bcb1d79fd..a12b9e2389 100644 --- a/Python/import.c +++ b/Python/import.c @@ -985,7 +985,7 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = PyObject_CallFunctionObjArgs(hook, p, NULL); + importer = _PyObject_CallArg1(hook, p); if (importer != NULL) break; -- 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(). --- Python/import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index a12b9e2389..6bcb1d79fd 100644 --- a/Python/import.c +++ b/Python/import.c @@ -985,7 +985,7 @@ get_path_importer(PyObject *path_importer_cache, PyObject *path_hooks, PyObject *hook = PyList_GetItem(path_hooks, j); if (hook == NULL) return NULL; - importer = _PyObject_CallArg1(hook, p); + importer = PyObject_CallFunctionObjArgs(hook, p, NULL); if (importer != NULL) break; -- cgit v1.2.1 From e29cd26d1dfebb2d8ba06fdad88223dec0762cba Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Dec 2016 16:09:30 +0100 Subject: Use _PyObject_CallMethodIdObjArgs() Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() in various modules when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string. --- Python/import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index 6bcb1d79fd..aef18005e2 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1705,7 +1705,7 @@ PyImport_ReloadModule(PyObject *m) Py_INCREF(imp); } - reloaded_module = _PyObject_CallMethodId(imp, &PyId_reload, "O", m); + reloaded_module = _PyObject_CallMethodIdObjArgs(imp, &PyId_reload, m, NULL); Py_DECREF(imp); return reloaded_module; } -- 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. --- Python/import.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index aef18005e2..38976f6b57 100644 --- a/Python/import.c +++ b/Python/import.c @@ -260,8 +260,7 @@ _imp_acquire_lock_impl(PyObject *module) #ifdef WITH_THREAD _PyImport_AcquireLock(); #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -283,8 +282,7 @@ _imp_release_lock_impl(PyObject *module) return NULL; } #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } void @@ -1853,8 +1851,7 @@ _imp_init_frozen_impl(PyObject *module, PyObject *name) if (ret < 0) return NULL; if (ret == 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } m = PyImport_AddModuleObject(name); Py_XINCREF(m); -- cgit v1.2.1 From 2da5419cea8ee7c2332331c45ab96b295011bdff Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 4 Feb 2017 11:53:22 +0200 Subject: Removed redundant Argument Clinic directives. --- Python/import.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Python/import.c') diff --git a/Python/import.c b/Python/import.c index 38976f6b57..53c0f4defb 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2042,11 +2042,6 @@ _imp_exec_builtin_impl(PyObject *module, PyObject *mod) return exec_builtin_or_dynamic(mod); } -/*[clinic input] -dump buffer -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ - PyDoc_STRVAR(doc_imp, "(Extremely) low-level import machinery bits as used by importlib and imp."); -- cgit v1.2.1