[Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

Barry Scott barry at barrys-emacs.org
Sat Jul 21 05:38:44 EDT 2018


Eric,

> On 17 Jul 2018, at 20:35, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> 
> With this in mind, here's how I'm approaching the problem:
> 
> 1. interp A "shares" an object with interp B (e.g. through a channel)
>    * the object is incref'ed under A before it is sent to B
> 2. the object is wrapped in a proxy owned by B
>    * the proxy may not make C-API calls that would mutate the object
> or even cause an incref/decref
> 3. when the proxy is GC'd, the original object is decref'ed
>    * the decref must happen in a thread in which A is running

How does the proxy at the same time make the object accessible and prevent mutation?

Would it help if there was an explicit owning thread for each object?

I'm thinking that you can do a fast check that the object belongs to the current thread and can use that knowledge to avoid locking.
If the object is owned by another thread acquire the GIL in the traditional way and mutating the state will be safe.

The "sharing" process can ensure that until an explicit "unsharing" the object remains safe to test in all threads that share an object,
avoiding the need for the special processor instructions.

Barry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180721/2e92e6d2/attachment-0001.html>


More information about the Python-ideas mailing list