On Mon, Sep 9, 2019, 09:27 Vinay Sharma via Python-ideas < python-ideas@python.org> wrote:
> Also, I didn't mean simple variables to be atomic. I just mean that > some objects which are frequently being used across processes in > multiprocessing can have some atomic operations/methods. > So, as Andrew suggested, you are talking about synchronization between processes on access to shared data, right? [snip] > In the above code snippet, I have to use a lock so as to prevent data > races, and using lock is quite straightforward and simple. But in cases > where I have to synchronize let's say 5 different values. I will have to > use multiple locks for synchronization, as using a single lock will be very > slow, and I will have to wait if a lock has been acquired to update any one > of the 5 values. > It isn't clear how a single lock wouldn't help. Could you provide an example of the more complex case? How would "atomic" multi-proc types help? Also, as far as I know (might be wrong) Value is stored in shared memory > and is therefore very fast also. So, what I am proposing is a similar > object to value to which operations like add, sub, xor, etc are atomic. > Therefore, I wouldn't have to use lock at all for synchronization. > Wouldn't such a type just use locks behind the scenes? Updates > to these values can be made very easily by using calls such as > __sync_and_and_fetch(), even when they are stored in a shared memory > segment, accessible across processes. > So you want a concurrency-safe wrapper around multiple operations? I'm unclear why this can't just be done with locks. -eric
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/RNQ5W7VERIXXHQ56ZJU3KDVLGU2KTTQB/ Code of Conduct: http://python.org/psf/codeofconduct/