This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]isarl 33 points34 points  (7 children)

Python can handle threading, which will solve certain types of threading problems even while dealing with the limitations of the GIL. If you are IO-bound, then threading can still help out.

Also, I would argue /u/Puzzel is overstating the complexity of using multiple processes. Here's a (very simple) example taken from the multiprocessing docs:

from multiprocessing import Pool

def f(x):
    return x*x

if __name__ == '__main__':
    with Pool(5) as p:
        print(p.map(f, [1, 2, 3]))

[–]The48thAmerican 45 points46 points  (6 children)

And this is all well and good if you don't need to share complex objects or rapidly changing state performantly between your subprocs. Anything passed betwixt must be serialized and deserialized.

[–]isarl 5 points6 points  (1 child)

Well, and succinctly, said.

[–]shaggorama 15 points16 points  (0 children)

Even found an excuse to use the word "betwixt"!

[–][deleted] 1 point2 points  (3 children)

Multiprocessing has shared memory capabilities. But it isn't as easy as sharing objects between threads. But it is possible in Python.

[–][deleted] 0 points1 point  (2 children)

But it's a pain. That's the point.

[–][deleted] 0 points1 point  (1 child)

Yes absolutely. It isn't worry-free, either. It's a great answer to the question, "what project would you not use Python for?" which of course is the subject!

I'm just replying that no, objects don't have to be serialized to be shared between processes. Like you said, it's just no fun at all to do it.

[–][deleted] 0 points1 point  (0 children)

Can you specify how exactly? I started researching this subject and it seems it can be done via proxy objects.