Add a new PyUnicode_Fill() function
It is faster than the unicode_fill() function which was implemented in
formatter_unicode.c.
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index dfd594e..6255dc3 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -623,11 +623,11 @@
#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 @@
);
#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.