[issue13155] Optimize finding the max character width

Antoine Pitrou report at bugs.python.org
Wed Oct 12 01:14:19 CEST 2011


New submission from Antoine Pitrou <pitrou at free.fr>:

This patch optimizes scanning for the max character width in an unicode buffer.

Micro-benchmarking some worst case situations:

$ ./python -m timeit -s "x='é'+'x'*100000" "x[1:]"
-> before:
10000 loops, best of 3: 74.9 usec per loop
-> after:
100000 loops, best of 3: 15.5 usec per loop

$ ./python -m timeit -s "x='\U00010000'+'x'*100000" "x[1:]"
-> before:
10000 loops, best of 3: 138 usec per loop
-> after:
10000 loops, best of 3: 71.3 usec per loop

----------
components: Interpreter Core
files: find_max_char.patch
keywords: patch
messages: 145372
nosy: pitrou
priority: normal
severity: normal
status: open
title: Optimize finding the max character width
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file23379/find_max_char.patch

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


More information about the Python-bugs-list mailing list