New submission from Gaëtan de Menten: In isspace, isalpha, isalnum and isdigit, I see code like:
/* Shortcut for single character strings */ if (PyString_GET_SIZE(self) == 1 && isspace(*p)) return PyBool_FromLong(1); Is it intentional to not use: if (PyString_GET_SIZE(self) == 1)) return PyBool_FromLong(isspace(*p) != 0); which would be faster when the result is False (but a tad slower when it is True because of the extra comparison). Also, is there a reason (other than historical) why the macros Py_RETURN_TRUE and Py_RETURN_FALSE are not used instead of their equivalent functions PyBool_FromLong(1) and PyBool_FromLong(0)? See: http://hg.python.org/cpython/file/e87364449954/Objects/stringobject.c#l3324 ---------- components: Interpreter Core messages: 185338 nosy: gdementen priority: normal severity: normal status: open title: str.is* implementation seem suboptimal for single character strings type: performance _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17559> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com