Solving the problem of mutual recursion

Ian Kelly ian.g.kelly at gmail.com
Sun May 26 15:35:52 EDT 2013


On Sun, May 26, 2013 at 12:13 PM, Peter Brooks
<peter.h.m.brooks at gmail.com> wrote:
> No, on a multi-core machine it's normal. The machine shows python
> running multiple threads - and the number of threads change as the
> program runs. Perhaps the OS/X implementation of python does allow
> concurrency when others don't. It certainly looks like it!

I'm pretty sure that CPython uses the GIL regardless of platform.  And
yes you can have multiple OS-level threads, but because of the GIL
only one will actually be running at a time.  Other possibilities
include:

1) You're using a different implementation of Python that does not
have a GIL, e.g. Jython or IronPython (well, probably not the latter).
 I believe PyPy also has a GIL-less version, although I don't think
this is in the current release yet.

2) You're using a fork of CPython that removes the GIL.  There are a
number of these, but none to my knowledge that are able to maintain
the performance of CPython for a single thread.

3) You're mistakenly looking at multiple Python processes that are
running simultaneously and adding their usages together.

4) The utility you're using is reporting the process CPU usage incorrectly.

5) Maybe for some reason the Mac OS X build of CPython is using
spin-locks in the GIL.  I can't imagine why this would be the case.



More information about the Python-list mailing list