I was wondering what would be the best way, performance wise, to pass shared arguments to threads (e.g. an input Queue).
I used to pass them as arguments to the __init__ function, because that's what I saw in most of the examples out there in the internet. But I was wondering whether it would be faster to set them as class variables, is there a reason not to do that?
Here is what I mean:
class Worker(threading.Thread):
def __init__(self, in_q):
self.in_q = in_q
or:
class Worker(threading.Thread):
in_q = None
def __init__(self):
...
...
def main():
Worker.in_q = Queue.Queue()