[pygtk] odd performance discrepancies between
gtk.ListStore.insert() and gtk.ListStore.append()
Michael Urman
murman at gmail.com
Wed Mar 1 23:00:39 WST 2006
On 3/1/06, Johan Dahlin <jdahlin at async.com.br> wrote:
> 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.
Stuff like this drives me batty. There are all these speed pitfalls
that don't correspond to a programmer's intuition about what may be
slow. In python, list.append is the optimized case where
list.insert(0, x) is slow because it has to shift the entire list over
one. C++ std::vector is the same. Only naive linked lists are
different, but it's still easy to make append just as fast as insert.
Trying to make a responsive application that works with lots of data
is hard enough without stumbling on things like this. How can I help
remove or at least highlight these problems so future development
doesn't trip over them?
Michael
--
Michael Urman http://www.tortall.net/mu/blog
More information about the pygtk
mailing list