[issue14716] Use unicode_writer API for str.format()

STINNER Victor report at bugs.python.org
Fri May 4 00:08:17 CEST 2012


New submission from STINNER Victor <victor.stinner at gmail.com>:

I just added a new "unicode_writer" API for the issue #14687 (Optimize str%tuple for the PEP 393) which helps to make "str%tuple" between 25% and 30% faster.

Attached patch replaces PyAccu API with the unicode_writer API for str.format().

Python 3.2:

1000000 loops, best of 3: 0.198 usec per loop
100000 loops, best of 3: 11.3 usec per loop
10000000 loops, best of 3: 0.167 usec per loop
1000000 loops, best of 3: 0.494 usec per loop

Python 3.3:

1000000 loops, best of 3: 0.293 usec per loop
10000 loops, best of 3: 20.2 usec per loop
1000000 loops, best of 3: 0.219 usec per loop
1000000 loops, best of 3: 0.909 usec per loop

Python 3.3 + patch (speed up of the patch):

1000000 loops, best of 3: 0.226 usec per loop (-22%)
100000 loops, best of 3: 14.8 usec per loop (-26%)
1000000 loops, best of 3: 0.219 usec per loop (0%)
1000000 loops, best of 3: 0.658 usec per loop (-27%)

----------
components: Interpreter Core
files: unicode_format_writer.patch
keywords: patch
messages: 159879
nosy: haypo, kristjan.jonsson, loewis, pitrou, python-dev, storchaka
priority: normal
severity: normal
status: open
title: Use unicode_writer API for str.format()
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file25445/unicode_format_writer.patch

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


More information about the Python-bugs-list mailing list