[PyQt] QGraphicsView very slow under Linux and Mac OS X

Clemens Brunner clemens.brunner at tugraz.at
Thu Apr 4 15:46:26 BST 2013


On 04/03/2013 05:09 PM, Andreas Pakulat wrote:

> As I said, with Qt4.8 I don't see this here on Linux at all, once the
> window is at a certain size the timer fires every 25 ms again. This is
> on a somewhat new system with Debians standard Qt/PyQt packages. So its
> not necessarily a general problem with Linux/PyQt, but might be limited
> to the systems you've used so far to reproduce this or a configuration
> thing etc.

Strange. I tried it on my Arch Linux as well as on openSUSE (inside 
VirtualBox), and I never get 25ms... I do get 25ms on Windows inside 
VirtualBox though. Plus I do get 25ms on all platforms when I run the 
C++ version.

> It could also be the fact that the various helpers inside your paint are
> slower in Python on *nix for whatever reason. Did you try further
> simplifying the paint function, for example simply painting 1 line
> across the whole rect in multiple steps? Or try out a single step? That
> way you'd be able to get rid of all the math which could affect the
> result too.
>[...]
>
> I doubt there's much difference in the PyQt/PySide code between Windows
> and *nix, after all the C API of CPython is the same on both platforms.
> One difference though is the compiler being used for both - at least
> usually it is a different one - and of course the platform itself. Does
> a fixed-length sleep instead of the paint() function produce a different
> result on Linux? Meaning, does it matter what exactly happens in paint
> or that its just not a noop?

It does depend on how much I draw. If I only fill the backgrounds, I get 
25ms. However, if I get rid of all the math functions and just paint a 
constant line, the program gets slower when this line is visible:

def paint(self, painter, option, widget):
         painter.fillRect(option.exposedRect, self.bg)
         for x in range(int(option.exposedRect.left()), 
int(option.exposedRect.right())):
             painter.drawLine(x-1, 20, x, 40)

I will talk about the output of perf in my reply to Hans-Peter's post.

Clemens


More information about the PyQt mailing list