Author inada.naoki
Recipients inada.naoki
Date 2019-06-20.11:40:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
_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().
Date User Action Args
2019-06-20 11:40:57inada.naokisetrecipients: + inada.naoki
2019-06-20 11:40:57inada.naokisetmessageid: <>
2019-06-20 11:40:57inada.naokilinkissue37348 messages
2019-06-20 11:40:57inada.naokicreate