[docs] [issue13246] Py_UCS4_strlen and friends needn't be public

STINNER Victor report at bugs.python.org
Sun Oct 23 11:08:30 CEST 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

> It seems there's no reason to document these functions
> which operate on null-terminated unicode arrays.

It's the easiest way to create a new string with the new Unicode API, when it's difficult to predict the exact output length and maximum character:

Py_UCS4 *buffer = PyMem_Malloc(...);
...
str = PyUnicode_FromKindAndBuffer(buffer, PyUnicode_4BYTE_KIND);
PyMem_Free(buffer);

PyUCS4_* functions are useful in the "..." (to write characters, expecially when you manipulate multiple strings).

For examples, see Python/import.c which used char*, then Py_UNICODE* and now Py_UCS4*. It's maybe possible to avoid functions like xxx_strlen(), but it was easier to replace str*() functions by Py_UNICODE_* and then PyUCS4_* functions.

--

Py_UNICODE_* and PyUCS4_* functions are not part of the stable API.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13246>
_______________________________________


More information about the docs mailing list