3 ms·
To nuance your comment, you can still get some form of parallelism, "just not" thread parallelism in Python. You can still spawn multiple handler process, or ha
by antoinealb 7y ago
To nuance your comment, you can still get some form of parallelism, "just not" thread parallelism in Python. You can still spawn multiple handler process, or have threaded code in a C extension.
- zepto 7y agoIt’s arguable whether either of those are ‘in python’.
- quacker 7y agoThe multiprocessing module in the standard library is absolutely a Python-native way to do parallelism: with Pool(5) as p: print(p.map(f, [1, 2, 3])) This runs f(1), f(2), and f(3) in parallel, using a pool of five processes. https://docs.python.org/3.6/library/multiprocessing.html https://docs.python.org/3.6/library/multiprocessing.html
- goostavos 7y agoWhoa! It never occurred to me that `Pool` could be used with context manager. I've always typed out `.close()` manually like a sucker.
- kbutler 7y agohttps://docs.python.org/2/library/multiprocessing.html https://docs.python.org/2/library/multiprocessing.html Python standard library since 2.6. Pretty much the definition of "in python".
- eloff 7y agoYes, you can use multiple processes to get the parallelism. But that's quite limiting compared with goroutines. Passing data back and forth is hard, and you can petty much forget about shared data structures. Memory usage is also much higher.