3 ms·
I think he's saying that they allow you to do concurrency, but not parallelism. Those are two different things.
by anaphor 7y ago
I think he's saying that they allow you to do concurrency, but not parallelism. Those are two different things.
- zbentley 7y agoThey do allow you to do parallelism, though. There are just some things they can't parallelize because of the GIL. Green threads also allow for parallelism, if they're scheduled onto more than one executor.
- anaphor 7y agoThat's true, behind the scenes they can be running on multiple CPUs, which is the definition of parallelism. I think threads are a bad abstraction for doing parallelism personally, though. Programs designed to run in parallel should be deterministic, unless they need concurrency for some other reason. I think trying to shoehorn parallel programming into Python's threads isn't necessarily the best approach. As far as I'm concerned, if I'm using threads and they happen to get scheduled on to multiple cores, then that's a nice optimization, but isn't necessary for what I use threads for.
- tellak 7y agoIf that’s what he’s saying, he’s wrong. Python threads are based on native threads. They are parallel executed, they just don’t do so very well because of the GIL.