GObject.Value destructor is slow
While investigating CPU usage in a gi app, GObject.Value.__del__
appears to be surprisingly slow:
ncalls tottime percall cumtime percall filename:lineno(function) ...
1224 0.011 0.000 0.011 0.000 GObject.py:220(__del__)
Replacing the body of __del__
with an unconditional unset()
and base class call like:
def __del__(self):
self.unset()
# We must call base class __del__() after unset.
super(Value, self).__del__()
Drops runtime to the more reasonable, but IMHO for such a fundamental type, still way too high:
ncalls tottime percall cumtime percall filename:lineno(function)
1224 0.005 0.000 0.006 0.000 GObject.py:220(__del__)
The destructor seems to be due to dd2a6c36 .. I'm not sure I understand the binding's design sufficiently, or indeed the original problem, but it seems odd that any Python code could trigger a memory access violation, and so it seems the original bug may have been fixed in the wrong place.
Could this destructor perhaps be moved into C?