[issue14744] Use _PyUnicodeWriter API in str.format() internals

STINNER Victor report at bugs.python.org
Wed May 9 13:53:46 CEST 2012


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

> Inlining may be removed to simplify the code

Attached inline_unicode_writer.patch does inline the code but also call only unicode_writer_prepare() once for each argument in PyUnicode_Format(). The patch removes unicode_writer_write_char() and unicode_writer_write_str() which had an overhead for the following patches (format_writer.patch, format_writer-2.patch).

> As you can see, there is a regress, and sometimes
> it is not less than improvement.

Oh yes, thanks for your benchmark. I will analyze why my patch slows down these cases and try to update my patch to be applicable after inline_unicode_writer.patch. I suppose that the _PyUnicodeWriter API has a little overhead which is seen by microbenchmarks.

----------
Added file: http://bugs.python.org/file25509/inline_unicode_writer.patch

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


More information about the Python-bugs-list mailing list