threading and multicores, pros and cons

Rhamphoryncus rhamph at gmail.com
Thu Feb 15 04:45:52 EST 2007


On Feb 14, 4:30 pm, "MRAB" <goo... at mrabarnett.plus.com> wrote:
> Hmm. I wonder whether it would be possible to have a pair of python
> cores, one for single-threaded code (no locks necessary) and the other
> for multi-threaded code. When the Python program went from single-
> threaded to multi-threaded or multi-threaded to single-threaded there
> would be a switch from one core to the other.

I have explored this option (and some simpler variants).  Essentially,
you end up rewriting a massive amount of CPython's codebase to change
the refcount API.  Even all the C extension types assume the refcount
can be statically initialized (which may not be true if you're trying
to make it efficient on multiple CPUs.)

Once you realize the barrier for entry is so high you start
considering alternative implementations.  Personally, I'm watching
PyPy to see if they get reasonable performance using JIT.  Then I can
start hacking on it.

--
Adam Olsen, aka Rhamphoryncus




More information about the Python-list mailing list