[PyQt] PyQt metrics

Hans-Peter Jansen hpj at urpla.net
Thu Dec 9 17:40:01 GMT 2010


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.PaintContext)
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 know, why. Find them, when piping the output of the script to 
less with: /^fail

With Qt 4.7, libQtAssistantClient.so* is not available anymore. Consequently 
importing QtAssistant fails. It might be a good idea to suppress building/
installing it as well in this case.

The result list was created with: python PyQtMetrics.py | grep ^Metr

python: 2.6
sip: 4.12-snapshot-b202f0d04ba6
qt4: 4.7.1
pyqt4: snapshot-4.8.2-8b918f4306e1

Pete
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PyQtMetrics.py
Type: application/x-python
Size: 2809 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20101209/2434c408/attachment-0001.bin>


More information about the PyQt mailing list