Alexander Belopolsky <belopol...@users.sourceforge.net> added the comment:
Thanks for the review and the tests. I have found one more place that can be easily optimized. (See patch below.) The decode() methods in bytes and bytearray are not so easy unfortunately because for some reason they are written to accept any object as self, not only byte/bytearray. As a result, it is not that easy to short-circuit default case in these instances. With respect to the patch below, I'll make sure that there is a test for it. =================================================================== --- Python/getargs.c (revision 88545) +++ Python/getargs.c (working copy) @@ -1010,8 +1010,6 @@ /* Get 'e' parameter: the encoding name */ encoding = (const char *)va_arg(*p_va, const char *); - if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); /* Get output buffer parameter: 's' (recode all objects via Unicode) or @@ -1051,9 +1049,12 @@ arg, msgbuf, bufsize); /* Encode object; use default error handling */ - s = PyUnicode_AsEncodedString(u, - encoding, - NULL); + if (encoding == NULL) + s = PyUnicode_AsUTF8String(u); + else + s = PyUnicode_AsEncodedString(u, + encoding, + NULL); Py_DECREF(u); if (s == NULL) return converterr("(encoding failed)", ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11313> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com