[issue31654] ctypes should support atomic operations
Daniel Colascione
report at bugs.python.org
Sun Oct 1 13:55:33 EDT 2017
Daniel Colascione <dancol at google.com> added the comment:
On Oct 1, 2017 10:19 AM, "Raymond Hettinger" <report at bugs.python.org> wrote:
Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:
> Compare-and-exchange is sufficient for avoiding the GIL contention
> I describe above.
If Python objects are involved, it is more complicated than you suggest.
Python objects are not involved. We're talking about memory manipulation on
the same level as ctypes.memmove.
Possibly, multiprocessing can offer a shared counter that creates integer
objects on demand and that offers guaranteed atomic increments and
decrements (as semaphores) do.
Why would it, when ctypes can provide generic functionality?
> one of the nice things about multiprocessing is avoiding
> GIL-introduced latency!
The primary way it achieves this benefit is by avoiding shared state
altogether.
Well, yes, but sometimes shared state is unavoidable, and it's best to
manipulate it as efficiently as possible.
----------
nosy: +davin, pitrou, rhettinger
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31654>
_______________________________________
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31654>
_______________________________________
More information about the Python-bugs-list
mailing list