New submission from Inada Naoki <songofaca...@gmail.com>:
_PyUnicode_FromASCII(s, len) is faster than PyUnicode_FromString(s) because PyUnicode_FromString() uses temporary _PyUnicodeWriter to support UTF-8. But _PyUnicode_FromASCII("hello", strlen("hello"))` is not as easy as `PyUnicode_FromString("hello")`. _PyUnicode_FROM_ASCII() is simple macro which wraps _PyUnicode_FromASCII which calls strlen() automatically: ``` /* Convenient wrapper for _PyUnicode_FromASCII */ #define _PyUnicode_FROM_ASCII(s) _PyUnicode_FromASCII((s), strlen(s)) ``` I believe recent compilers optimize away calls of strlen(). ---------- components: Interpreter Core messages: 346115 nosy: inada.naoki priority: normal severity: normal status: open title: add _PyUnicode_FROM_ASCII macro type: performance versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37348> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com