[Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

Benjamin Peterson benjamin at python.org
Thu Nov 7 23:29:37 CET 2013


2013/11/7 Victor Stinner <victor.stinner at gmail.com>:
> Calling strlen() at runtime may slow-down a function in the fast-path
> of PyUnicode_Decode() and PyUnicode_AsEncodedString() which are
> important functions. I know that some developers can execute strlen()
> during compilation, but I don't see the need of replacing 6 with
> strlen("utf-8")+1.

GCC will fold constant strlen calls. Another option would be to use sizeof().


-- 
Regards,
Benjamin


More information about the Python-Dev mailing list