STINNER Victor added the comment: 2013/11/14 Serhiy Storchaka <rep...@bugs.python.org>: > And what will be PyAccu vs PyUnicodeWriter comparison when increase PyAccu > overallocating rate too?
PyAccu doesn't use a Unicode buffer, but a list of strings. PyUnicode_Join() is used to compact the list. PyAccu uses an hardcoded limit of 100,000 items before compacting. PyUnicodeWriter has a different design, it gives access to the buffer. So functions like PyUnicode_WRITE() can be used directly. The design allows a little bit optimizations. Example: - s = PyUnicode_FromString("["); - if (s == NULL || _PyAccu_Accumulate(&acc, s)) + if (_PyUnicodeWriter_WriteChar(&writer, '[') < 0) In list_repr(), it shouldn't make a big difference. But it helps me in str%args and str.format(args) to avoid large temporary strings. For example, "%.100s" writes directly padding into the buffer, instead of having to allocate a long string, copy characters, and then destroy the padding string. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19513> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com