DEV Community

Discussion on: Choosing Python for Web Development: Top 16 Pros and Cons

Collapse
 
antontsvil profile image
Anton T

Great write up! Could you elaborate on what you mean by Python not having "true" multiprocessor support?

Collapse
 
rdil profile image
Reece Dunham

I'm pretty sure that the meaning of this is that Python doesn't handle this stuff well - dealing with it is a pain. I would love Python to the end of time if it just had multithreading that worked.

Collapse
 
loki profile image
Loki Le DEV

Python has what is called the "Global Interpreter Lock", you can read more here: docs.python.org/3/c-api/init.html#...

Meaning that when you launch multiple threads in the same python interpreter they are actually locked on one core and can't be really parallelized. For some applications it's not a real issue, when your threads spend most of the time sleeping/waiting for IO for example. But when you need real parallel computing on multiple cores you can't do it with threads.
Python provides the "multiprocessing" module to workaround this, launching code in separate processes. It makes it a bit harder but not impossible to do real multi core parallelization.

Collapse
 
antontsvil profile image
Anton T

Thanks for your explanation! So if I'm understanding correctly the only real way to do parallel processing is to have multiple python processes separate from each other. But that means the data used by each process is sort of isolated, right?

Thread Thread
 
loki profile image
Loki Le DEV

Yes, the multiprocessing module provides some tools to exchange this data: docs.python.org/2/library/multipro... but your data needs to be easily serializable which is not always the case.

Thread Thread
 
rhymes profile image
rhymes

@antontsvil , I personally think the article is a bit misleading becuase it mixes different details under umbrella terms but @loki already explained what's going on in Python :)