This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients loewis, mark.dickinson, pitrou, python-dev, serhiy.storchaka, vstinner
Date 2012-05-28.14:01:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAMpsgwZbCBydgP3y6k60CBdK4Pp5rUCx8Of4Ku=bN7O__H=_iA@mail.gmail.com>
In-reply-to <CAMpsgwYbvCO46NCZzc_NKM5T0tzj58bFQS-z=1FF1rsQ7VjvzA@mail.gmail.com>
Content
So, do you have any comment or complain? Or can I commit the patch?
Le 24 mai 2012 11:57, "STINNER Victor" <report@bugs.python.org> a écrit :

>
> STINNER Victor <victor.stinner@gmail.com> added the comment:
>
> >> For Python 3.3, _PyUnicodeWriter API is faster than the Py_UCS4 buffer
> API and PyAccu API in quite all cases, with a speedup between 30% and 100%.
> But there are some cases where the _PyUnicodeWriter API is slower:
> >
> > Perhaps most of these problems can be solved if instead of the boolean
> > flag (overallocate/no overallocate) to use the Py_ssize_t parameter that
> > indicates by how much should you overallocate (it is the length of the
> > suffix in the format).
>
> There is not only a flag (flags.overallocate): there is also the
> min_length, which is used and helps for str%args and str.format(args).
>
> My patch contains a lot of "tricks" to limit overallocation, e.g.
> don't overallocate if we are writing the last part of the output.
>
> Computing exactly the size of the buffer gives the best performance
> because it avoids a resize in _PyUnicodeWriter_Finish(). I tried for
> example to modify PyUnicode_Format() to parse the format string twice:
> first to compute the size of the output buffer, second to write
> characters. In my experience, parsing the format string twice is more
> expensive than reallocating the buffer (PyUnicode_READ is expensive),
> especially on short and simple format strings.
>
> I tried different methods to allocate the buffer of _PyUnicodeWriter:
> change the overallocation factor (0%, 25%, 50%, 100%), only
> overallocate +100 characters, etc. But I failed to find something
> better than the proposed patch.
>
> At least I can say than always disabling overallocation slows done
> many cases: when there is a suffix after an argument, or when there
> are more than one argument.
>
> Feel free to experiment other methods to estimate the size of the output
> buffer.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue14744>
> _______________________________________
>
History
Date User Action Args
2012-05-28 14:01:36vstinnersetrecipients: + vstinner, loewis, mark.dickinson, pitrou, python-dev, serhiy.storchaka
2012-05-28 14:01:35vstinnerlinkissue14744 messages
2012-05-28 14:01:35vstinnercreate