[PyQt] PyQt metrics

Phil Thompson phil at riverbankcomputing.com
Thu Dec 9 21:49:01 GMT 2010


On Thu, 9 Dec 2010 22:31:38 +0100, "Hans-Peter Jansen" <hpj at urpla.net>
wrote:
> On Thursday 09 December 2010, 19:46:26 Baz Walter wrote:
>> On 09/12/10 17:40, Hans-Peter Jansen wrote:
>> > Hi Phil, hi *,
>> >
>> > ever wanted to know, how many classes and methods PyQt4 provides?
>> >
>> > I'm not sure, if my calculations are valid, but according to my Q&D
>> > script (attached), they are:
>> >
>> > Metric(name: PyQt4.phonon, modules: 1, classes: 52, methods: 2274,
>> > functions: 0) Metric(name: PyQt4.Qsci, modules: 1, classes: 83,
>> > methods: 3790, functions: 0) Metric(name: PyQt4.QtCore, modules: 1,
>> > classes: 358, methods: 4670, functions: 69) Metric(name:
>> > PyQt4.QtDeclarative, modules: 1, classes: 43, methods: 1124,
>> > functions: 0) Metric(name: PyQt4.QtDesigner, modules: 1, classes:
>> > 45, methods: 2230, functions: 0) Metric(name: PyQt4.QtGui, modules:
>> > 1, classes: 1288, methods: 42198, functions: 18) Metric(name:
>> > PyQt4.QtHelp, modules: 1, classes: 55, methods: 2082, functions: 0)
>> > Metric(name: PyQt4.QtMultimedia, modules: 1, classes: 21, methods:
>> > 284, functions: 0) Metric(name: PyQt4.QtNetwork, modules: 1,
>> > classes: 118, methods: 1723, functions: 0) Metric(name:
>> > PyQt4.QtOpenGL, modules: 1, classes: 29, methods: 686, functions:
>> > 0) Metric(name: PyQt4.QtScript, modules: 1, classes: 26, methods:
>> > 254, functions: 2) Metric(name: PyQt4.QtScriptTools, modules: 1,
>> > classes: 4, methods: 57, functions: 0) Metric(name: PyQt4.Qt,
>> > modules: 1, classes: 2218, methods: 61963, functions: 90)
>> > Metric(name: PyQt4.QtSql, modules: 1, classes: 30, methods: 749,
>> > functions: 0) Metric(name: PyQt4.QtSvg, modules: 1, classes: 13,
>> > methods: 634, functions: 0) Metric(name: PyQt4.QtTest, modules: 1,
>> > classes: 4, methods: 25, functions: 0) Metric(name: PyQt4.QtWebKit,
>> > modules: 1, classes: 51, methods: 1476, functions: 3) Metric(name:
>> > PyQt4.QtXmlPatterns, modules: 1, classes: 21, methods: 262,
>> > functions: 0) Metric(name: PyQt4.QtXml, modules: 1, classes: 60,
>> > methods: 1235, functions: 0) Metric(name: PyQt4, modules: 19,
>> > classes: 4519, methods: 127716, functions: 182)
>> >
>> > I would be glad, if someone with with Python introspection
>> > knowledge could look into the script, and check, if I'm not missing
>> > something obvious.
>> >
>> > A few notes:
>> >
>> > I had to ignore a few classes, as they lead to recursive behavior:
>> > "pyqtProperty", "pyqtSignal", "pyqtWrapperType", "wrappertype",
>> > "enumtype"
>> >
>> > Some methods aren't inspectable:
>> >>>> import PyQt4
>> >>>> import inspect
>> >>>> inspect.getmembers(QtGui.QAbstractTextDocumentLayout.PaintContex
>> >>>>t)
>> >
>> > Traceback (most recent call last):
>> >    File "<stdin>", line 1, in<module>
>> >    File "/usr/lib/python2.6/inspect.py", line 257, in getmembers
>> >      value = getattr(object, key)
>> > AttributeError: 'PaintContext' object attribute 'clip' is an
>> > instance attribute
>>
>> i don't get this error with either:
>>
>>     
>> inspect.getmembers(QtGui.QAbstractTextDocumentLayout.PaintContext)
>>
>> or:
>>
>>     
>> inspect.getmembers(QtGui.QAbstractTextDocumentLayout.PaintContext())
>>
>> > I don't know, why. Find them, when piping the output of the script
>> > to less with: /^fail
>>
>> i don't see any "fail" lines, at all.
>>
>> (this is using: python 2.7.1, qt 4.7.1, sip 4.11.2, pyqt 4.8.1)
> 
> Thanks for testing, Baz. 
> 
> Just retried with:
> python: 2.6
> sip: 4.11.2
> qt4: 4.7.1
> pyqt4: 4.8.1
> 
> and I still do get them. The major difference between our setups is
> Python now, but I cannot switch that one painlessly.
> 
> Any idea, Phil?

I confirm the exception with Python 2.6.5, but Python 2.7.1 is fine.

Phil


More information about the PyQt mailing list