[PyQt] PyQt5 + Python 3: passing lists, dicts as signal arguments across threads
Mathias.Born at gmx.de
Mathias.Born at gmx.de
Thu Sep 25 21:28:10 BST 2014
On 25.09.2014, 21:44:15 Alan Ezust wrote:
> In C++, I pass QList and QMap by value as signal arguments and I
> know that there will be lazy copy on write, and I can safely use the
> variables of these types when needed.
Actually, you cannot.
Quoting http://qt-project.org/doc/qt-5/containers.html :
"In addition, they are thread-safe in situations where they are
used as read-only containers by all threads used to access them."
This doesn't come as a surprise, because locking can be very
expensive.
Best Regards,
Mathias
> And if I pass by pointer or
> reference, I know I need to protect concurrent access to it.
> In PyQt5, there is no QList or QMap, and it seems the list and dict
> built-ins are automatically converted to/from QList/QMap when needed.
> Which is nice.
> So now my question is, when a list or dict is passed as a signal
> argument across thread boundaries, what happens? Is it passed by
> reference? If so, do we need to protect it from access in the other thread?
> Or does it behave like QList and QMap and have lazy copy on write?
> Is this documented somewhere?
More information about the PyQt
mailing list