[Tutor] Python on multicore machines

OkaMthembo zebra05 at gmail.com
Fri Nov 27 16:30:23 CET 2009


Thanks Kent, that did clear some of the smog.

>At least make sure you understand the difference between threads and
processes.

Will be taking that advice. I think it's the reason i struggle to ask the
question better.

On Fri, Nov 27, 2009 at 5:12 PM, Kent Johnson <kent37 at tds.net> wrote:

> On Fri, Nov 27, 2009 at 8:57 AM, OkaMthembo <zebra05 at gmail.com> wrote:
> > Thanks, i must admit the concept of the GIL is cloudy to me - for
> example,
> > if the python interpreter on a single machine is
> > handling one process and locks until it is done, then on to the next one,
> > and so on - isn't that what causes speed issues?
>
> A single interpreter runs in a single process. Within that process,
> only one thread can be interpreting Python byte codes at one time. If
> a thread is blocked, for example waiting for I/O, another thread can
> run. Some C extensions release the GIL so other threads can run
> concurrently.
>
> > I was wondering why python can't implicitly handle multiple processes at
> > once by using all machine cores (have many threads, each
> > invoking the interpreter and handling a process).
>
> Because explicit is better than implicit?
>
> The multiprocessing module allows you to control multiple processes
> from Python and do pretty much what you describe above - a Python main
> program can create multiple processes, each running a separate
> interpreter, all working on a single problem.
>
> > Maybe i should get up to speed on threads first to get the bigger
> picture?
>
> At least make sure you understand the difference between threads and
> processes.
>
> Kent
>



-- 
Regards,
Lloyd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091127/a96f25a3/attachment.htm>


More information about the Tutor mailing list