This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane
Date 2019-06-20.11:40:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561030857.7.0.211621244107.issue37348@roundup.psfhosted.org>
In-reply-to
Content
_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().
History
Date User Action Args
2019-06-20 11:40:57methanesetrecipients: + methane
2019-06-20 11:40:57methanesetmessageid: <1561030857.7.0.211621244107.issue37348@roundup.psfhosted.org>
2019-06-20 11:40:57methanelinkissue37348 messages
2019-06-20 11:40:57methanecreate