From d3f0882dfb3a15d604de1b1620b2bf8de9d643bb Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 29 May 2012 12:57:52 +0200 Subject: Issue #14744: Use the new _PyUnicodeWriter internal API to speed up str%args and str.format(args) * Formatting string, int, float and complex use the _PyUnicodeWriter API. It avoids a temporary buffer in most cases. * Add _PyUnicodeWriter_WriteStr() to restore the PyAccu optimization: just keep a reference to the string if the output is only composed of one string * Disable overallocation when formatting the last argument of str%args and str.format(args) * Overallocation allocates at least 100 characters: add min_length attribute to the _PyUnicodeWriter structure * Add new private functions: _PyUnicode_FastCopyCharacters(), _PyUnicode_FastFill() and _PyUnicode_FromASCII() The speed up is around 20% in average. --- Include/floatobject.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Include/floatobject.h') diff --git a/Include/floatobject.h b/Include/floatobject.h index 0ca4881a32..46ef6e6062 100644 --- a/Include/floatobject.h +++ b/Include/floatobject.h @@ -112,10 +112,12 @@ PyAPI_FUNC(int) PyFloat_ClearFreeList(void); /* Format the object based on the format_spec, as defined in PEP 3101 (Advanced String Formatting). */ -PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj, - PyObject *format_spec, - Py_ssize_t start, - Py_ssize_t end); +PyAPI_FUNC(int) _PyFloat_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); #endif /* Py_LIMITED_API */ #ifdef __cplusplus -- cgit v1.2.1