What does @Slot() do?

Excellent tutorial! I appreciate your effort to write for both PyQT5 and PySide2 libraries.
Can we get some more information on the @Slot() lines? The code works without as well (PySide2 QT5.2.13 on *ubuntu1910)

On the PyQt5 site, it is stated that

Connecting a signal to a decorated Python method has the advantage of reducing the amount of memory used and is slightly faster.

But then THIS site challenges that statement and provides some performance & memory tests.

I actually had the same thought when working on the recent updates to the book – “is this still necessary?!” – and tested removing it from the examples. It worked fine in some cases, but in others would give to segfaults. Reading up on it I understand the distinction as –

  1. if you decorate a method with pyqtSlot then that slot is created as a native Qt slot, and behaves identically

  2. if you don’t decorate the method then PyQt with create a “proxy” object wrapper which provides a native slot to Qt

The second raises an issue in threading re: where the proxy object should live – in the GUI thread or the executing thread? In the case of the run method for runners it should always be in the runner thread, but it can (apparently?) potentially end up in the wrong place, leaving vars to be accessed from two separate threads (= a segfault). That said, this mechanism all seems to be particular to PyQt5.

I should do some more in depth testing, see if I can get a reproducible example.