[Urwid] How do you use SimpleListWalker?

Ian Ward ian at excess.org
Fri Jun 19 14:39:41 EDT 2009


Dominic LoBue wrote:
> What makes SimpleListWalker inappropriate for larger lists? For a quick test
> I used Text rather than Button, but I'm able to scroll through all 2600
> conversation threads rather quickly. No CPU spikes or anything.

There are all the usual reasons for not wanting big lists, which are
implemented as arrays in python:
- Inserting items is O(n)
- Deleting items is O(n)
- Must fit in memory*

Also for Urwid you will need to create all your widgets for every item
in advance, which can introduce delays.

There should be no performance problem when scrolling the ListBox, it is
oblivious to where the widgets are coming from.  With custom ListWalker
classes you do need to think about this though, because you can
introduce delays with long calculations in get_next or get_prev.  The
browse.py program has this problem when it reads directories for the
first time.  Ideally it should create a temporary "Loading..." widget
and replace it when done loading and sorting.

Ian


* python gets a bad reputation because of programmers that don't think
about this when working with huge data structures, for example old
versions of "yum"







More information about the Urwid mailing list