Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Atomic Operations in Python?

I'm a beginner in Python. Now I read about Threading and I have some questions.

IMO Atomic Operations (AO) = the simplest operation. the simplest operation in dev is a = 1. But I did read the article (http://preshing.com/20130618/atomic-vs-non-atomic-operations/) and I got the impression that it did not the simplest operation\AO. The author told us this operation divided into two operations and this operation wasn't AO. That this operation was AO it had to have another type. But I must say he told about C/C++ and bytecode, I think the same in Python. How I understood this depend on a type and maybe compiler. BUT Python is dynamic types of language. It has no types.

And I decided to ask the community these questions:

  1. What are Atomic Operations in Python?

  2. Which operations are AO in Python?

If the simple operation isn't simple then I do not understand what is Atomic Operations.

like image 490
Pro Avatar asked Dec 18 '22 17:12

Pro


1 Answers

The Python documentation's FAQ seems to have a pretty good answer to this question under What kinds of global value mutation are thread-safe?

I hope you understand the difference between a local stack variable, or a variable otherwise private to a particular thread, that won't have issues with thread safety, and a global or shared variable that will.

like image 137
CryptoFool Avatar answered Dec 31 '22 09:12

CryptoFool