[PyKDE] Method wrappers not shared
Giovanni Bajo
rasky at develer.com
Fri Oct 28 15:05:56 BST 2005
Phil:
>>> import qt
>>> a = qt.QWidget.acceptDrops
>>> b = qt.QWidget.acceptDrops
>>> a is b
False
>>> id(a), id(b)
(9674384, 9670704)
>>> id(qt.QWidget.acceptDrops)
9831568
>>> id(qt.QWidget.acceptDrops)
9831568
It looks like these method wrappers are recreated each time I need them (I
believe it has to do with the lazy binding construction, right)? Would it be
possible to change SIP so that it preserves existing methods and reuses
them, or is it too much work?
This would be needed for tools like epydoc. Basically, given an object like
qt.QWidget.acceptDrops, epydoc has no way to find it looking within the
module qt, nor it has a way to understand through inspection that
qt.QWidget.acceptDrops come from qt.pyd (the __module__ attribute contains
None, and __objclass__ does not exist).
I know this is really a minor issue, but I would like to get it fixed.
Basically, epydoc can't be used altogether on PyQt applications because it
wastes too much time looking for thousands of duplicates of each and every
method of each and every qt class, in each and every module which does "from
qt import *". Ewww.
Another fix which would be good for me would be to have the __module__
attribute defined for methods. Probably easier to implement than reusing
method objects?
--
Giovanni Bajo
More information about the PyQt
mailing list