[Python-Dev] [ANN]: "newthreading" - an approach to simplified thread usage, and a path to getting rid of the GIL

Michael Foord fuzzyman at voidspace.org.uk
Sat Jun 26 15:29:24 CEST 2010


On 26/06/2010 07:11, John Nagle wrote:
> We have just released a proof-of-concept implementation of a new
> approach to thread management - "newthreading". It is available
> for download at
>
> https://sourceforge.net/projects/newthreading/
>
> The user's guide is at
>
> http://www.animats.com/papers/languages/newthreadingintro.html

The user guide says:

The suggested import is

from newthreading import *

The import * form is considered bad practise in *general* and should not 
be recommended unless there is a good reason. This is slightly off-topic 
for python-dev, although I appreciate that you want feedback with the 
eventual goal of producing a PEP - however the introduction of 
free-threading in Python has not been hampered by lack of 
synchronization primitives but by the difficulty of changing the 
interpreter without unduly impacting single threaded code.

Providing an alternative garbage collection mechanism other than 
reference counting would be a more interesting first-step as far as I 
can see, as that removes the locking required around every access to an 
object (which currently touches the reference count). Introducing 
free-threading by *changing* the threading semantics (so you can't share 
non-frozen objects between threads) would not be acceptable. That 
comment is likely to be based on a misunderstanding of your future 
intentions though. :-)

All the best,

Michael Foord
>
> This is a pure Python implementation of synchronized objects, along
> with a set of restrictions which make programs race-condition free,
> even without a Global Interpreter Lock. The basic idea is that
> classes derived from SynchronizedObject are automatically locked
> at entry and unlocked at exit. They're also unlocked when a thread
> blocks within the class. So at no time can two threads be active
> in such a class at one time.
>
> In addition, only "frozen" objects can be passed in and out of
> synchronized objects. (This is somewhat like the multiprocessing
> module, where you can only pass objects that can be "pickled".
> But it's not as restrictive; multiple threads can access the
> same synchronized object, one at a time.
>
> This pure Python implementation is usable, but does not improve
> performance. It's a proof of concept implementation so that
> programmers can try out synchronized classes and see what it's
> like to work within those restrictions.
>
> The semantics of Python don't change for single-thread programs.
> But when the program forks off the first new thread, the rules
> change, and some of the dynamic features of Python are disabled.
>
> Some of the ideas are borrowed from Java, and some are from
> "safethreading". The point is to come up with a set of liveable
> restrictions which would allow getting rid of the GIL. This
> is becoming essential as Unladen Swallow starts to work and the
> number of processors per machine keeps climbing.
>
> This may in time become a Python Enhancement Proposal. We'd like
> to get some experience with it first. Try it out and report back.
> The SourceForge forum for the project is the best place to report 
> problems.
>
> John Nagle
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk 
>


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.




More information about the Python-Dev mailing list