Xiang Zhang added the comment: The cost is really small (an integer compare vs memory malloc and copy). The advantages are fast path for empty strings and retaining consistency with other codes in unicodeobject.c. You can see other places use the same optimization, e.g. PyUnicode_FromUnicode, PyUnicode_FromUCS1, and some functions using unicode_result.
---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28398> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com