Multiple scripts versus single multi-threaded script
Chris Angelico
rosuav at gmail.com
Thu Oct 3 12:50:00 EDT 2013
On Fri, Oct 4, 2013 at 2:41 AM, Roy Smith <roy at panix.com> wrote:
> The downside to threads is that all of of this sharing makes them much
> more complicated to use properly. You have to be aware of how all the
> threads are interacting, and mediate access to shared resources. If you
> do that wrong, you get memory corruption, deadlocks, and all sorts of
> (extremely) difficult to debug problems. A lot of the really hairy
> problems (i.e. things like one thread continuing to use memory which
> another thread has freed) are solved by using a high-level language like
> Python which handles all the memory allocation for you, but you can
> still get deadlocks and data corruption.
With CPython, you don't have any headaches like that; you have one
very simple protection, a Global Interpreter Lock (GIL), which
guarantees that no two threads will execute Python code
simultaneously. No corruption, no deadlocks, no hairy problems.
ChrisA
More information about the Python-list
mailing list