[PyQt] Bug (and fix!): laggy interactive input on Windows

Chris Billington chris.billington at monash.edu
Wed Oct 22 18:51:06 BST 2014


To whom it may concern,

The input hook function qtcore_input_hook() in
sip/QtCore/qcoreapplication.sip appears to be the cause of laggy
interactive input on Windows my colleagues and I been seeing. This mostly
comes up when using matplotlib interactively with the PyQt backend (default
in popular Windows Python distributions) - input keystrokes lag behind by
some significant fraction of a second, making things pretty unusable.

If one reduces the timeout in qtcore_input_hook()from 100ms to 10ms, the
lag becomes completely unnoticeable and input is responsive once more. This
increases Python's idle CPU usage from 0.03% to 0.3% on my machine.

Attached is a script that demonstrates this in Python, and patches for
sip/QtCore/qcoreapplication.sip to reduce the timeout (If I have given
these patches in the wrong format I apologize - it is a single character
deletion so maybe providing patches is silly anyway).

This applies to both PyQt4 and PyQt5.

Thanks,

Chris Billington

-- 
Chris Billington
School of Physics
Monash University
Victoria 3800, Australia
Ph: +61 423952456
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141022/5cd5dda8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqt_inputhook_demonstration.py
Type: application/octet-stream
Size: 1349 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141022/5cd5dda8/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqt4-qcoreapplication.sip.patch
Type: application/octet-stream
Size: 317 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141022/5cd5dda8/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqt5-qcoreapplication.sip.patch
Type: application/octet-stream
Size: 317 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20141022/5cd5dda8/attachment-0005.obj>


More information about the PyQt mailing list