Slow loading, moving base code to C



Hi,

Since Sugar was ported from GTK2/pygtk to GTK3/pygobject3, the desktop
and apps are considerably slower to launch. I'm trying to correct
this. You can see at least part of this slowdown by timing the
following 2 programs:

1. import gtk

2. from gi.repository import Gtk

cProfile shows that the biggest obvious offender is the getattr
implementation of IntrospectionModule, eats up quite a bit of CPU
time.

To get a feel for whether this would speed up if it were written in C,
I started to move the code into the _gi module. After starting to do
this, I think the answer is definitely yes. Most of its work is
getting basic info from GI and in order to that it crosses the
Python-C barrier many times, and all of the GI elements are wrapped in
their own python objects, etc. If it were all done in C and just
called into GI directly things would be faster and more direct.

I would be interested in finishing this work and the translation is
not that difficult, but I want to ask for some opinions first. Would
this kind of code movement be accepted?

Another consideration is how far to go. getattr instantiates
GObjectMeta objects and things like at. At first I would leave
GObjectMeta this in Python but we can measure later, maybe that would
also benefit from being done in C.

Daniel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]