[issue14687] Optimize str%tuple for the PEP 393
STINNER Victor
report at bugs.python.org
Thu May 3 03:41:25 CEST 2012
STINNER Victor <victor.stinner at gmail.com> added the comment:
> Parameters of the Unicode writer (overallocation factor
> and initial size) may be adjusted (later?) for better performances.
I tried to compute the initial size from the args object. It is hard because we don't know how arguments are used. For example, an argument may not be a number formatted as decimal, but the width of an argument. Another example: "%.3s" may be used to only read the 3 first characters of a very long string.
So I consider that it is *simpler and safer* to not guess anything from args, but only choose correctly the overallocation factor. I tried the following factors: 1 (no overallocation), 1.25, 1.5 and 2.0. It looks like 1.25 (pos*5/4) is the best compromise and offers the best performances.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14687>
_______________________________________
More information about the Python-bugs-list
mailing list