mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Add a new PyUnicode_Fill() function
It is faster than the unicode_fill() function which was implemented in formatter_unicode.c.
This commit is contained in:
parent
332503db07
commit
3fe553160c
4 changed files with 76 additions and 18 deletions
|
@ -623,11 +623,11 @@ PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
|
|||
#endif
|
||||
|
||||
/* Copy character from one unicode object into another, this function performs
|
||||
character conversion when necessary and falls back to memcpy if possible.
|
||||
character conversion when necessary and falls back to memcpy() if possible.
|
||||
|
||||
Fail if to is too small (smaller than how_many or smaller than
|
||||
Fail if to is too small (smaller than *how_many* or smaller than
|
||||
len(from)-from_start), or if kind(from[from_start:from_start+how_many]) >
|
||||
kind(to), or if to has more than 1 reference.
|
||||
kind(to), or if *to* has more than 1 reference.
|
||||
|
||||
Return the number of written character, or return -1 and raise an exception
|
||||
on error.
|
||||
|
@ -650,6 +650,23 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters(
|
|||
);
|
||||
#endif
|
||||
|
||||
/* Fill a string with a character: write fill_char into
|
||||
unicode[start:start+length].
|
||||
|
||||
Fail if fill_char is bigger than the string maximum character, or if the
|
||||
string has more than 1 reference.
|
||||
|
||||
Return the number of written character, or return -1 and raise an exception
|
||||
on error. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill(
|
||||
PyObject *unicode,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t length,
|
||||
Py_UCS4 fill_char
|
||||
);
|
||||
#endif
|
||||
|
||||
/* Create a Unicode Object from the Py_UNICODE buffer u of the given
|
||||
size.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue