Debian Codegraph @

docs/news/pygobject-3-56.rst

raw
1 :date: Feb 27, 2026
2 :author: Arjan Molenaar
3
4 PyGObject 3.56.0
5 ================
6
7 PyGObject 3.56.0 has just been released. Major features include: better integration with
8 GObject's lifecycle (``do_constructed``, ``do_dispose``), a simpler way to deal with
9 Python wrapper objects, and cleanup of legacy code.
10
11 GObject lifecycle methods
12 -------------------------
13
14 This release exposes two new GObject lifecycle hooks: ``do_constructed`` and ``do_dispose``.
15
16 * ``do_constructed`` is called after a GObject has been fully constructed.
17 * ``do_dispose`` is called when the underlying GObject (not just the Python wrapper) is disposed,
18 for example via :obj:`~gi.repository.GObject.Object.run_dispose`.
19
20 Slots
21 -----
22
23 Slots (``__slots__``) have never been officially supported in PyGObject, even though it worked in some cases.
24 With the new wrapping model (see below), using ``__slots__`` can cause issues.
25 PyGObject now emits a warning when ``__slots__`` is used in classes derived from GObject.
26
27 Shallow wrapper objects
28 -----------------------
29
30 PyGObject's Python object tracking used to be complex. In 3.56, wrapper lifecycle management has been simplified.
31
32 Previously, PyGObject retained Python wrapper objects when instance attributes existed,
33 using `toggle references <https://docs.gtk.org/gobject/method.Object.add_toggle_ref.html>`__.
34 Now, wrapper objects are always discardable. PyGObject preserves the instance dictionary and reapplies it to
35 new wrapper instances as needed. This behavior is easier to reason about and enables features such as ``do_dispose``.
36
37 Legacy code removal
38 -------------------
39
40 In 3.56, marshalling for fields, properties, constants, and signal closures has been replaced by the existing
41 function/method call marshalling logic. Because that path already supports more cases, this change resolves
42 multiple long-standing issues.
43
44 PyGObject is getting rid of custom wrapper logic. In this release, ``pygtkcompat`` and wrappers for
45 ``GLib.OptionContext/GLib.OptionGroup`` have been fully removed.
46
47 What's next
48 -----------
49
50 There is still more to improve. We need your help for that: if you spot un-pythonic behavior, create an issue.
51 Maybe you feel like fixing an issue even.