[PyQt] Method names from SIP-wrapped classes not showing in cProfile output

Phil Thompson phil at riverbankcomputing.com
Thu May 21 22:11:55 BST 2009


On Thu, 21 May 2009 20:49:38 +0200, Håkon Bertheussen
<haakon.bertheussen at gmail.com> wrote:
> I'm trying to profile some code that uses SIP wrapped classes
> extensively. I'm having a problem with the output from cProfile;
> method names of sip-wrapped classes are not showing, instead a string
> like "{sip.methoddescriptor object at 0x...}" is displayed. The thing
> is I know this used to work with a previous setup I had. Since then
> I've updated Python, SIP and PyQt, so I don't know which is the
> culprit. I'm using Python 2.6.2, PyQt-win-gpl-4.5-snapshot-20090507
> and sip-4.8-snapshot-20090430.
> 
> Example:
> 
> from PyQt4 import QtGui
> import cProfile
> 
> def test():
>     for _ in xrange(10):
>         image = QtGui.QImage(3000, 3000, QtGui.QImage.Format_ARGB32)
>         image.fill(QtGui.qRgb(50, 100, 150))
> 
> def main():
>     cProfile.run('test()')
> 
> if __name__=='__main__':
>     main()
> 
> This outputs:
> $>proftest.py
>          23 function calls in 0.324 CPU seconds
> 
>    Ordered by: standard name
> 
>    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
>         1    0.003    0.003    0.324    0.324 <string>:1(<module>)
>         1    0.024    0.024    0.321    0.321 proftest.py:4(test)
>        10    0.000    0.000    0.000    0.000 {PyQt4.QtGui.qRgb}
>         1    0.000    0.000    0.000    0.000 {method 'disable' of
>         '_lsprof.Prof
> iler' objects}
>        10    0.297    0.030    0.297    0.030 {sip.methoddescriptor
object
>        at 0x
> 0245D1B0}

How methods are wrapped has changed. However it's just a question of giving
sip.methoddescriptor a useful __repr__. What do you want it to say?

Phil


More information about the PyQt mailing list