[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
Hi Antoine, As you said there can be lot of possible use cases for the proposed feature, since there are lot’s of use cases for a lock. I can tell you some cases which I am facing. Let’s say I have a parent process which spawns lots of worker processes to serve some requests. Now the parent pr

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Antoine Pitrou
Hi Vinay, I see. I agree agregating statistics is a reasonable use case. Still, maintaining atomic types in the standard library sounds non-trivial for a rather niche feature. Perhaps you want to implement them as a third-party project and publish it on PyPI? multiprocessing already provides sh

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Rhodri James
On 13/09/2019 14:32, Vinay Sharma via Python-ideas wrote: As you said there can be lot of possible use cases for the proposed feature, since there are lot’s of use cases for a lock. I can tell you some cases which I am facing. I don't in principle object to having language support for tricky o

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
Please see my second mail in this thread, where I have comprehensively explained what I mean by atomic types. It is nothing but multiprocessing.Value, which can have an Atomic variant to be used across processes. >>> On 13-Sep-2019, at 8:37 PM, Rhodri James wrote: >> On 13/09/2019 14:32, Vinay

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Rhodri James
On 13/09/2019 17:07, Vinay Sharma wrote: Please see my second mail in this thread, where I have comprehensively explained what I mean by atomic types. It is nothing but multiprocessing.Value, which can have an Atomic variant to be used across processes. Doesn't multiprocessing.Value already h

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
multiprocessing.Value can be synchronised using a lock, but if I have multiple multiprocessing.Value(s) which I want to synchronise between two processes, then I will have to pass a lock for each multiprocessing.Value. Therefore having a multiprocessing.AtomicValue could prove handy in these cas

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Vinay Sharma via Python-ideas
If you see my first mail, I have mentioned that gcc has support for atomic builtins, which can be used to support atomic behaviour. You can refer gcc’s documentation for the same at https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/_005f_005fsync-Builtins.html#g_t_005f_005fsync-Builtins

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Richard Musil
On Fri, Sep 13, 2019 at 6:27 PM Rhodri James wrote: > On 13/09/2019 17:07, Vinay Sharma wrote: > > Please see my second mail in this thread, where I have comprehensively > explained what I mean by atomic types. > > It is nothing but multiprocessing.Value, which can have an Atomic > variant to be

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Rhodri James
On 13/09/2019 17:31, Vinay Sharma wrote: multiprocessing.Value can be synchronised using a lock, but if I have multiple multiprocessing.Value(s) which I want to synchronise between two processes, then I will have to pass a lock for each multiprocessing.Value. Therefore having a multiprocessing

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Richard Musil
On Fri, Sep 13, 2019 at 6:56 PM Rhodri James wrote: > I repeat, how does this work? If you want atomicity across processes, > you need some kind of lock at some level. > For the atomic operations the lock is on the hardware level (i.e. implemented in the CPU, across the mem BUS, cache, etc.), f

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
First, I’m pretty sure that, contrary to your claims, C++ does not support this. C++ doesn’t even support shared memory out of the box. The third-party Boost library does provide it—as long as you only care about systems that correctly supports POSIX shared memory, and Windows, and as long as yo

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
On Sep 13, 2019, at 09:31, Vinay Sharma via Python-ideas wrote: > > multiprocessing.Value can be synchronised using a lock, but if I have > multiple multiprocessing.Value(s) which I want to synchronise between two > processes, then I will have to pass a lock for each multiprocessing.Value. Th

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Antoine Pitrou
On Fri, 13 Sep 2019 10:27:10 -0700 Andrew Barnert via Python-ideas wrote: > > (If you want a shiny modern solution instead, this looks like one of the few > cases where hardware TM support can probably speed things up relatively > easily, which would be a fun project to work on…) Hardware tran

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
On Sep 13, 2019, at 10:11, Richard Musil wrote: > > For the atomic operations the lock is on the hardware level (i.e. implemented > in the CPU, across the mem BUS, cache, etc.), from the user perspective, it > looks only like executing a particular (atomic) op-code. > (https://software.intel.c

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
On Sep 13, 2019, at 10:42, Antoine Pitrou wrote: > > On Fri, 13 Sep 2019 10:27:10 -0700 > Andrew Barnert via Python-ideas > wrote: >> >> (If you want a shiny modern solution instead, this looks like one of the few >> cases where hardware TM support can probably speed things up relatively >> e

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Richard Musil
On Fri, Sep 13, 2019 at 7:28 PM Andrew Barnert via Python-ideas < [email protected]> wrote: > First, I’m pretty sure that, contrary to your claims, C++ does not support > this. C++ doesn’t even support shared memory out of the box. The > third-party Boost library does provide it—as long as y

[Python-ideas] Re: Support for atomic types in Python

2019-09-13 Thread Andrew Barnert via Python-ideas
> On Sep 13, 2019, at 12:21, Richard Musil wrote: > >> On Fri, Sep 13, 2019 at 7:28 PM Andrew Barnert via Python-ideas >> wrote: > >> First, I’m pretty sure that, contrary to your claims, C++ does not support >> this. C++ doesn’t even support shared memory out of the box. The third-party >>