[Urwid] Unbearable slowness in UTF-8 mode

Ian Ward ian at excess.org
Wed Oct 11 12:19:24 EDT 2006

Nuutti Kotivuori wrote:
> 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.

A workaround is to call urwid.set_encoding('ascii'), but that's not a 

Currently Urwid redraws all the visible widgets every time you call 
render.  The Text widgets do cache the result of their alignment and 
wrapping, but Urwid might be calling calc_width unnecessarily on text it 
should already know the width of.

Would you post a simple example that demonstrates the problem?


More information about the Urwid mailing list