After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 704023 - Move type_from_name back to a static bindings for optimization
Move type_from_name back to a static bindings for optimization
Status: RESOLVED WONTFIX
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 693243
 
 
Reported: 2013-07-11 17:26 UTC by Simon Feltman
Modified: 2013-09-12 07:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Replace usage of type_from_name with static bindings (3.28 KB, patch)
2013-07-14 17:01 UTC, Simon Feltman
rejected Details | Review

Description Simon Feltman 2013-07-11 17:26: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
Comment 1 Simon Feltman 2013-07-14 17:01:24 UTC
Created attachment 249129 [details] [review]
Replace usage of type_from_name with static bindings
Comment 2 Simon Feltman 2013-07-14 17:09:06 UTC
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
Comment 3 Simon Feltman 2013-09-12 07:53:55 UTC
As mentioned in comment #2, testing shows this does nothing for performance.