[pygtk] odd performance discrepancies between gtk.ListStore.insert() and gtk.ListStore.append()

Johan Dahlin jdahlin at async.com.br
Wed Mar 1 22:33:04 WST 2006


Jason Gerard DeRose wrote:
> In my work on FUPlayer, I discovered an odd performance discrepancies
> between gtk.ListStore.insert() and gtk.ListStore.append(), namely that
> insert() is significantly faster than append().
> 
> In my benchmarks, run under Ubuntu Breezy (pygtk 2.8.1, gtk 2.8.6),
> populating a ListStore using insert() ran in 77% the time of append().
> To me this suggests a bug in pygtk or gtk.

That is expected. If you rewrite the program in C you'll most likely notice
a similar difference. The implementation of append() needs to know the
length of the list, where insert() does not.

If that part of your program is performance sensitive you should use insert
and reverse the list after all inserts are done.

-- 
Johan Dahlin <jdahlin at async.com.br>
Async Open Source


More information about the pygtk mailing list