GNOME Bugzilla – Bug 704023
Move type_from_name back to a static bindings for optimization
Last modified: 2013-09-12 07:54:07 UTC
type_from_name was moved from static bindings to use the introspected version. This seems to affect load times and since the function is simple enough we should look at moving it back as a static method: https://git.gnome.org/browse/pygobject/commit/?id=da2106902eb3d $ cat profile_test.py from gi.repository import GObject, Gio, GLib, Gtk, Gdk, Pango, Clutter, Gst $ python -m cProfile -s tottime profile_test.py 93580 function calls (92149 primitive calls) in 0.106 seconds Ordered by: internal time ncalls tottime cumtime filename:lineno(function) 46 0.021 0.021 {method 'invoke' of 'gi.CallableInfo' objects} This is used in the GObject overrides to create the series of pre-defined "TYPE_XYZ" module variables: https://git.gnome.org/browse/pygobject/tree/gi/overrides/GObject.py?id=3.8.3#n110
Created attachment 249129 [details] [review] Replace usage of type_from_name with static bindings
Review of attachment 249129 [details] [review]: While the number of calls was cut down, I did not notice any actual load time performance improvement. Not sure what this means. Rejecting until this is actually proven useful. $ cat profile_gtk.py from gi.repository import Gtk $ cat ntime #!/usr/bin/env bash TIMEFORMAT='scale=3; %3U + %3S' total=0.0 count=$1 shift for i in $(seq 1 $count) do current=$(echo $( { time $@ 2>/dev/null; } 2>&1 ) | bc) total=$(echo "scale=3; $total + $current" | bc) done echo "scale=3; $total / $count" | bc BEFORE: $ python -m cProfile -s tottime profile_gtk.p ncalls tottime percall cumtime percall filename:lineno(function) 29 0.023 0.001 0.023 0.001 {method 'invoke' of 'gi.CallableInfo' objects} 24 0.000 0.000 0.000 0.000 {gi._gobject._gobject.type_from_name} $ ntime 100 python profile_gtk.py .071 AFTER: $ python -m cProfile -s tottime profile_gtk.p ncalls tottime percall cumtime percall filename:lineno(function) 3 0.015 0.005 0.015 0.005 {method 'invoke' of 'gi.CallableInfo' objects} 49 0.000 0.000 0.000 0.000 {gi._gobject._gobject.type_from_name} $ ntime 100 python profile_gtk.py .071
As mentioned in comment #2, testing shows this does nothing for performance.