[Urwid] Unbearable slowness in UTF-8 mode
naked at iki.fi
Wed Oct 11 10:55:56 EDT 2006
When I was testing urwid originally, I was somewhat amazed by it's
speediness. Usually console applications feel somewhat sluggish
somehow, but the urwid test programs had none of that.
However, when using an UTF-8 capable terminal, I get unbearable
performance. For example in a simple columns example I have, where a
column changes background color based on focus, urwid takes half a
second of CPU time to just process the right arrow key in a 80x76
terminal. Same thing happens in a really simple application that just
has one edit box - typing characters easily maxes out the CPU and
characters arrive bunched up several at once in the input loop.
I did some tracing of the problem and discovered that
urwid.util.calc_width function was what caused the performance
difference - calculation of actual text widths in utf8 is obviously
much harder to do than in normal 8-bit encodings. By forcing the
calc_width function to use the same method of calculating widths as
with ASCII, the performance problems went away.
In any case, this slowness is a showstopper for me - and I'm wondering
what would be the best way to optimize this.
More information about the Urwid