[pygtk] Overriding GObject methods in Python
Hrvoje Nikšić
hrvoje.niksic at avl.com
Fri Nov 24 00:17:03 WST 2006
On Thu, 2006-11-23 at 14:23 +0100, Ed Catmur wrote:
> > Another option would be to forego properties and use a separate
> > vtable
> > object in the class structure. The object would encapsulated the
> > binding of slot to GClosure, and could be exported to Python. It
> > seems
> > like reinventing the wheel, though.
>
> The wheel you're reinventing is GObject signals.
You're right. I thought of signals as primarily a notification
mechanism. I assume you're referring to the technique of implementing
the dispatch by emitting the signal, as described at
http://le-hacker.org/papers/gobject/ch05s03.html#id2778308 ?
I'm a bit worried about performance of that. As far as I can tell, you
cannot optimize for the case of methods implemented in C being called
from C; the emit/notification cycle always marshals the arguments to
GValues and back. This offers excellent flexibility, but at the price
of efficiency of the common case.
I hoped for a solution where the arguments are marshalled only when
calling actual Python code (a method implemented in a Python subclass),
and simply transmitted when the method is implemented in C.
More information about the pygtk
mailing list