Message346115
_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:57 | methane | set | recipients:
+ methane |
2019-06-20 11:40:57 | methane | set | messageid: <1561030857.7.0.211621244107.issue37348@roundup.psfhosted.org> |
2019-06-20 11:40:57 | methane | link | issue37348 messages |
2019-06-20 11:40:57 | methane | create | |
|