First Python 2.7 interpreter to use multiple cores
mail.python.org
mail.python.org
[1] You may argue (correctly) that multiprocessing and using pipes to communicate is a better solution than threads to begin with (for many applications). However, sometimes a threaded solution is the right solution and previously if you needed threads python didn't work for you.
The GIL is released during the execution of some C code, so another thread may execute Python code in the meantime, but that's probably besides the point too.
This is how Python programs can show up using more than 100% CPU in `top`.
http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2010-und... covers this
But I think it's a slight oversell to call this a python 2.7 interpreter. For instance, most scientific computing code that runs in cpython 2.7 won't run on pypy.
It's impressive from a computer science point of view. But, pypy has a ways to go before I'd call it a python interpreter without adding qualifications.
Pure python? or stuff written in/depending on C modules like NumPy? PyPy is supposed to be 2.7 compliant if pure python, while C extension support is still experimental.
Note that this is independent of CPython development.
Also it's not CPython. Technically, if you want the GIL to be gone on Python in general you can already use IronPyton or Jython which do not use a global interpreter lock.
Current documentation: https://bitbucket.org/pypy/pypy/raw/stm-thread/pypy/doc/stm....
The plan: http://pypy.org/tmdonate.html
I'm a bit disappointed that Python seems to have no interest in standardizing a lightweight-thread (greenlet, coroutine) interface that isn't an awful mess. yield is powerful but coroutine implementations with it are baroque and opaque. Java-style threading has a million gotchas and the interface is just a dog. I want to be able to teach people with a week of experience to write concurrent programs. (What about writing turtle programs with multiple turtles running at the same time?)
If Python doesn't do it, then I want someone else to eat their lunch.
I'd rather Python moved in the direction of go than Java
If it's within 5% though, I'll be happy - especially if the backend is possible to switch. It seems that it's possible now - so if you know you're running only in a single thread you could just choose the cut-down version.
Given that, and given that the patches for removing the GIL were submitted for an earlier version a while back (2.4 or before, I believe), is it unfeasible/impossible to design an interpreter that detects whether a program requires support for multiple threads and then act accordingly? Since this currently requires the inclusion of a module, it seems like it would be unambiguous.
Of course, the slow path would just use STM all the time.
I mean, that is non-trivial.
I think this could be achieved in a simple way in a similar fashion - some sort of a straightforward 'multithreaded' pragma shouldn't be too much of a burden.