2

I'm aware that Jython and IronPython can run threads in parallel(to take advantage Multicore or SMP machines) due to their VM implementation. Is there an implementation or extension in CPython that does that ? I'm not talking about multiprocessing as in http://docs.python.org/library/multiprocessing.html

How "heavy" are the sub processes in the multiprocessing module compared to threads in the JVM or .Net ? Is there an overhead of the python runtime for every Process object ?

I've also seen stackless "way" of Tasklets for concurrency, but they use round robin scheduling and cant run Tasklets in parallel.

2
  • 1
    Regular CPython threads are actually fully parallel system threads -- they just acquire a mutually exclusive GIL. Thus, CPython [C] extensions which do not acquire the GIL avoid this mutual exclusion to running. The downside? Don't mess with CPython objects unless you have the GIL :) The core "issue" is simply how CPython was designed -- or not designed -- to work across threads. It takes a simpler approach at the expense of not being able to concurrently execute Python (under the GIL). Commented May 26, 2011 at 20:39
  • Threads that wait on the network (e.g. making HTTP requests) can also effectively run in parallel, although that's not taking advantage of multiple cores. Commented May 26, 2011 at 21:18

1 Answer 1

6

The multiprocessing module uses full processes. That means it fork()s. So this are not threads like the usual POSIX threads you usually mean by talking about threads.

Sign up to request clarification or add additional context in comments.

1 Comment

I've found a very nice video for the GIL and for threads in python us.pycon.org/2010/conference/schedule/event/76

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.