GNOME Bugzilla – Bug 687988
should not use guint-based GSource APIs
Last modified: 2012-11-12 15:15:02 UTC
memory-managed bindings should use the GSource*-based GSource APIs, not the guint-based ones, since a) in some programs, the IDs may eventually overflow and get reused (bug 687098) b) g_source_remove() is O(n), whereas g_source_destroy() is O(1) AIUI python has bignums, so in theory you could just convert the GSource*s from pointers to integers and back, and so not change the public API at all. Although that would break refcounting of the GSource* so maybe you wouldn't want that.
Hey Dan, I agree that in general that is a better idea. However, pygobject itself does not set up any event sources, it merely provides bindings to the GLib API. Where in pygobject's code did you see that? Thanks!
Ah, no, I didn't mean pygobject's own use, I meant that it should expose the GSource-based APIs as part of the pygobject API, so its consumers can use them rather than the guint-based ones.
In master we dropped all the static bindings, so it should actually be available now. Do you see a particular method which is still missing? E. g. for g_idle_add() glib does not have a direct equivalent, but you can do g_idle_source_new(). You can do the same in Python with "GLib.Idle()" and attaching that to a context yourself, just as in C.
ah, cool, I was basing this off comments in bug 687098, which apparently are about an older version of pygobject
Indeed; the correct handling of overflowing source IDs has been fixed in pygobject 3.4.2, and due to the removal of the static bindings it's not an issue any more in 3.7.x.