[PyQt] PyQt5 + Python 3: passing lists, dicts as signal arguments across threads

Mathias.Born at gmx.de Mathias.Born at gmx.de
Sat Sep 27 20:03:16 BST 2014

On 27.09.2014, 23:08:58 Alan Ezust wrote:

> On Thu, Sep 25, 2014 at 1:28 PM, <Mathias.Born at gmx.de> wrote:
> 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.

> cannot pass by value? I don't understand what you mean.

I just wanted to point out, that in C++ you cannot
"safely use the variables of these types when needed."
Not when writing, that is.

> 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.

> My question was about python dict and list though, not about Qt containers.

Since python dicts and lists are converted ("mapped types") and thus copied,
you should be safe. But I'm not entirely sure about this, thus I
kept quiet ...

Best Regards,

More information about the PyQt mailing list