[Urwid] Status update: Performance improvements

Ian Ward ian at excess.org
Fri Jan 26 16:03:53 EST 2007

The latest code in subversion has some major performance improvements. 
Here are some of the numbers I got when running bench_1 and bench_2:

trunk r67:  24% faster than
trunk r67 + rbreu-cmodule:  50% faster than

trunk r67: 135% faster than
trunk r67 + rbreu-cmodule: 150% faster than

Keep in mind that is much faster than all the 0.9 releases 
before it.

Also, the latest profiler results suggest that caching the column widths 
in the Columns widget might be worthwhile.

.. So, what has changed?

I've added a CompositeCanvas class that now handles all the 
AttrWrap-applying and Canvas-combining operations.  The old Canvas class 
  is now only used to store static text and attributes rendered from 
Text widgets, so that they can be cached and reused.

Caching is performed by a new CanvasCache class that uses weak 
references to the Canvas objects. The display modules will now keep a 
reference to the last CompositeCanvas that was used to render the screen 
in order to keep the Canvas objects alive in the cache while a new 
screen is being rendered.

These changes make use of features that are not available in Python 2.1, 
so this release requires Python 2.2 or higher.  I think this is a pretty 
conservative change, since Python 2.2 *has* been available for 5 years now.

Comments, suggestions and bug reports are always welcome.


More information about the Urwid mailing list