[PyQt] connections vs. instance variables

Sybren A. Stüvel sybren at stuvel.eu
Fri Sep 3 14:57:03 BST 2010


Hi Eric,

A direct call is always more lightweight, as no matter what else 
happens, somehow in the end a direct call to the slot has to be made.

Based on the 'type' parameter to the connect call, different things 
happen. The emitted signal can simply directly call the slot (default 
behaviour when both sender and receiver live in the same thread), or 
the signal can be stored in an event queue, from where it will be 
delivered later on (default behaviour when sender and receiver live in 
different threads).

Sybren

On Friday 03 September 2010 15:51:44 Eric Frederich wrote:
> I constantly find myself with options like...
> a) create a connection from foo's custom signal to bar's slot....
> or b) when creating the foo object, give it a reference to bar,
> and instead of emitting a custom signal, just call bar's slot
> directly.
> 
> What is more lightweight.... an instance variable or a connection?
> 
> I'm sure this must be common.
> Are there guidelines to use, rules of thumb etc?
> 
> Thanks,
> ~Eric

-- 
Sybren A. Stüvel

sybren at stuvel.eu
http://stuvel.eu/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100903/a6116f88/attachment.pgp>


More information about the PyQt mailing list