Discussion in 'Python' started by Dan Stromberg, Dec 12, 2013.

  1. On Thu, Dec 12, 2013 at 12:06 AM, marcinmltd <> wrote:
    > Hello,
    > I'm big fan of multiprocessing module, but recently I started looking at
    > threading in Python more closely and got couple of questions I hope You can
    > help me with:
    > 1. When I run two or more threads in my python process are they really run
    > concurrently on mulicore machine?
    > 2. Browsing through documentation it looks like python interpreter protects
    > its sensitive states by using GIL. Can you guys list situations when this
    > happens?
    > 2. What would be general advice from python experts on when to use threadng
    > and when switch to multliprocessing in python? Is the decision still
    > influenced by how often we need to comunicate between the tasks as it's in
    > C\C++?

    Jython and IronPython reportedly thread well generally.

    CPython threads I/O-bound tasks well, but as soon as you introduce one
    CPU-bound thread, the other threads start to have problems. Pypy is
    probably the same as CPython, at least until they get their STM
    working well.

    Multiprocessing can do CPU-bound and I/O-bound workloads, but starting
    a new process takes longer than starting a new thread (especially on
    Windows). Inter-thread/process communication is likely slower on
    multiprocessing than multithreading as well, but this is merely my

    Note: CPython is what a lot of people call "Python"; CPython is a new
    term for the original implementation to distinguish it from the other
    implementations that exist today.
    Dan Stromberg, Dec 12, 2013
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page