[issue31654] ctypes should support atomic operations

2017-10-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le 01/10/2017 à 23:33, Daniel Colascione a écrit : > > Huh? Both are very generic. "Specialized" as in "I didn't expect anyone would want to do such a thing in pure Python". > SCM_RIGHTS is "specialized" > and not supported on all systems,

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Daniel Colascione
Daniel Colascione added the comment: On Sun, Oct 1, 2017 at 2:01 PM, Antoine Pitrou wrote: > Perhaps other core developers will disagree with me and agree to include > (i.e. review, maintain) this functionality. I simply am not convinced > it

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Daniel Colascione
Daniel Colascione added the comment: On Sun, Oct 1, 2017 at 2:01 PM, Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > Le 01/10/2017 à 21:51, Daniel Colascione a écrit : > > > >> That does sound specialized to me :-)

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is not clear to me what API is needed, but I agree with Antoine that ctypes doesn't look the appropriate place for it. Maybe in multiprocessing or subprocess, or in low-level module providing primitives for multiprocessing or

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le 01/10/2017 à 21:51, Daniel Colascione a écrit : > >> That does sound specialized to me :-) Can you give an example of such a >> C API? > > The Linux futex protocol, as described in man futex(7), comes to mind. > Maybe you want to manipulate

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Daniel Colascione
Daniel Colascione added the comment: On Sun, Oct 1, 2017 at 11:12 AM, Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > Le 01/10/2017 à 20:04, Daniel Colascione a écrit : > > > > It's not that specialized. You might

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Daniel Colascione
Daniel Colascione added the comment: On Sun, Oct 1, 2017 at 11:14 AM, Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > Note that if there is already a C API to perform atomic ops, you can > simply use ctypes to invoke

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: Note that if there is already a C API to perform atomic ops, you can simply use ctypes to invoke that API. Unfortunately, the aforementioned GCC builtins seem to be only available as intrinsics (at least I couldn't find a shared library that

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le 01/10/2017 à 20:04, Daniel Colascione a écrit : > > It's not that specialized. You might want atomic updates for coordinating > with C APIs that expect callers to have this capability. That does sound specialized to me :-) Can you give an

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Daniel Colascione
Daniel Colascione added the comment: On Oct 1, 2017 10:46 AM, "Antoine Pitrou" wrote: Antoine Pitrou added the comment: While the use case is reasonable (if specialized), It's not that specialized. You might want atomic updates for

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Daniel Colascione
Daniel Colascione added the comment: On Oct 1, 2017 10:19 AM, "Raymond Hettinger" wrote: Raymond Hettinger added the comment: > Compare-and-exchange is sufficient for avoiding the GIL contention > I describe above. If

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: While the use case is reasonable (if specialized), I'm not sure ctypes is the place to expose such functionality, which can be quite extensive (see https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html). Perhaps as a separate

[issue31654] ctypes should support atomic operations

2017-10-01 Thread Raymond Hettinger
Raymond Hettinger 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. Possibly, multiprocessing can offer a shared counter that

[issue31654] ctypes should support atomic operations

2017-10-01 Thread SilentGhost
Change by SilentGhost : -- nosy: +amaury.forgeotdarc, belopolsky, meador.inge ___ Python tracker ___

[issue31654] ctypes should support atomic operations

2017-09-30 Thread Daniel Colascione
New submission from Daniel Colascione : Say we're using multiprocessing to share a counter between two processes and we want to atomically increment that counter. Right now, we need to protect that counter with a multiprocessing semaphore of some sort, then 1) acquire the