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 723736 - Add API for enabling features and fixes which break compatibililty
Add API for enabling features and fixes which break compatibililty
Status: RESOLVED OBSOLETE
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: 616279 652115 709976 731091
 
 
Reported: 2014-02-06 03:46 UTC by Simon Feltman
Modified: 2018-01-10 20:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add load time option to remove deprecated initializers (25.92 KB, patch)
2014-03-20 07:34 UTC, Simon Feltman
none Details | Review
Patch with the new table called "options" instead of "features". (25.91 KB, patch)
2014-03-20 07:42 UTC, Simon Feltman
none Details | Review

Description Simon Feltman 2014-02-06 03:46:42 UTC
The idea is to provide an API which allows for turning on (or off) features in PyGObject that would break API compatibility. Similar to Python's "from __future__ import X" statement.

It looks like there are some dead remnants of a similar API from PyGObject 2:
https://git.gnome.org/browse/pygobject/tree/gi/gobjectmodule.c?id=3.11.5#n2157

This uses a dictionary which offers a fairly clean API:
 gi.features['X'] = True
 gi.features['X'] = False
 gi.features['X']

We just need to button it up a bit and expose it as "gi.features" which is filled out with False defaults.

Some initial features which could make use of this:

* Deprecate initialize overrides (bug 705810). Since we can't actually remove the deprecated functions, it would be nice to explicitly disable the loading of them. By putting the overrides behind a logic test for classes which have these, we can improve load time performance for programs that need this speedup (Sugar OS).
  gi.features['skip_initializer_overrides']

* Skipping array/list length arguments for callbacks (bug 652115). We currently pass the length argument explicitly to callbacks. Changing this is an API break.
  gi.features['skip_redundant_callback_args']

* Zero copy support of arrays (bug 709976). Some API's which return GArrays coerced to Python lists would return a direct wrapper to the GArray. While the API could be made the same as a Python list, this might break some expectations callers have so it would need explicit enablement.
  gi.features['zero_copy_arrays']

* Propagate exceptions from callbacks (bug 616279). Fixing this would break caller expectations so would require explicit enablement.
  gi.features['propagate_callback_exceptions']
Comment 1 Simon Feltman 2014-03-20 07:34:38 UTC
Created attachment 272464 [details] [review]
Add load time option to remove deprecated initializers

Add gi.options dictionary to the main gi module. This gives a new
table for optional behavior in overrides and binding machinery
which may break things in a backwards incompatible way.

Add "remove_deprecated_initializers" option used in Gtk overrides
for blocking the loading of class overrides that only contain deprecated
initializers. When enabled, we get about a 12% performance boost when
importing Gtk. This can be enabled as follows:

    import gi
    gi.options['remove_deprecated_initializers'] = True
    from gi.repository import Gtk
Comment 2 Simon Feltman 2014-03-20 07:42:55 UTC
Created attachment 272465 [details] [review]
Patch with the new table called "options" instead of "features".
Comment 3 Simon Feltman 2014-03-20 07:50:22 UTC
Performance was tested as follows:

$ python3 -m timeit -n 1 -r 1 --setup "import gi; gi.options['remove_deprecated_initializers'] = False" "from gi.repository import Gtk"

1 loops, best of 1: 53.6 msec per loop


$ python3 -m timeit -n 1 -r 1 --setup "import gi; gi.options['remove_deprecated_initializers'] = True" "from gi.repository import Gtk"

1 loops, best of 1: 46.5 msec per loop

These are the best of about 10 runs each. While a performance improvement of 8 msec (13%) is not very much on my super computer :) This will most likely be a lot more significant on something like a raspberry pi or xo laptop.
Comment 4 GNOME Infrastructure Team 2018-01-10 20:37:24 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/65.