[Urwid] Optimize urwid - cutable benchmarks

Ian Ward ian at excess.org
Tue Jan 2 11:37:15 EST 2007

Rebecca Breu wrote:
> Check the attachment out. :)
> It contains an implementation of
>   * get_width
>   * decode_one
>   * decode_one_right
> in utable.py (as in urwid version
> It seems to work fine with test_urwid and the example programs, but I din't
> test it very thouroughly.
> I started on util.py as well, but I haven't had time to finish it yet.

Here are my bench_1 results (different computer this time):
   Minimum: 9.588382 with cutable:
   Minimum: 7.828077
   ~ 22% improvement

development version with my patch:
   Minimum: 3.201065

development version with my patch and cutable:
   Minimum: 3.070312
   ~ 4% improvement

But that's with my patch that avoids calling get_width and decode_one 
when a SAFE_ASCII regular expression of "safe" characters matches the 

development version without SAFE_ASCII_RE:
   Minimum: 8.828370

development version without SAFE_ASCII_RE, with cutable:
   Minimum: 7.279629
   ~ 21% improvement

I think that if we have a C version of util.calc_width we could have 
speed like the development version with SAFE_ASCII_RE but for *all* 
unicode strings.

Rebecca: Since it's just a few of the functions in util.py that need to 
be rewritten in C feel free to move those functions to utable.c if 
that's easier.


More information about the Urwid mailing list