[Urwid] urwid in pure unicore

Victor Stinner victor.stinner at haypocalc.com
Sat Dec 30 22:10:48 EST 2006


Hi,

Le Dimanche 31 Décembre 2006 01:37, Victor Stinner a écrit :
> The problem is in Canvas class. The attached patch is a proposition to fix
> the problem (double conversion). The idea is to store text encoded for the
> terminal (UTF-8) in Canvas.text but also to keep the Unicode version in
> Canvas.unitext.

Another approch is to cache calc_width() results. I attached two 
implementation:
 - dummy implementation: 7.8 sec => 2.1 sec (without any other patch)
 - LRU cache (500 entries): 7.8 => 2.3 sec (but requires Python 2.4 because of 
use of 'deque')

I don't like the idea of cache, but... it's also a solution to the performance 
problem. Problems: clear cache sometimes but also choose the good cache 
settings (cache size).

With the dummy implementation, the profiler show that :

calls  tottime  percall  cumtime  percall filename:lineno(function)
  124    0.611    0.005    1.309    0.011 curses_display.py:484(draw_screen)
 5386    0.462    0.000    1.138    0.000 canvas.py:37(__init__)
 4995    0.419    0.000    1.443    0.000 canvas.py:354(apply_text_layout)
 9748    0.319    0.000    1.055    0.000 urwid_ui.py:252(_get)
36491    0.285    0.000    0.285    0.000 util.py:877(rle_len)
  124    0.284    0.002    0.551    0.004 util.py:590(calc_text_pos)
  358    0.255    0.001    1.805    0.005 listbox.py:110(calculate_visible)

So next step: limit creation of Canvas. If we limit creation of Canvas, my 
last patches (keep widths values or cache calc_width result) may be useless.


But now I'm tired, it's near 4:00 :-)


~~~>  Happy new year ;-)  <~~~


Haypo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urwid_calc_width_cache.patch
Type: text/x-diff
Size: 1271 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20061231/464a539c/urwid_calc_width_cache-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urwid_calc_width_cache_lru.patch
Type: text/x-diff
Size: 2972 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20061231/464a539c/urwid_calc_width_cache_lru-0001.bin


More information about the Urwid mailing list