Answer the question
In order to leave comments, you need to log in
How to figure out which operation is atomic?
For example, the list.append(x) operation is atomic, how can this be understood from the python bytecode?
>>> def k():
... l = []
... l.append(10)
...
>>> dis(k)
2 0 BUILD_LIST 0
2 STORE_FAST 0 (l)
3 4 LOAD_FAST 0 (l)
6 LOAD_ATTR 0 (append)
8 LOAD_CONST 1 (10)
10 CALL_FUNCTION 1
12 POP_TOP
14 LOAD_CONST 0 (None)
16 RETURN_VALUE
Answer the question
In order to leave comments, you need to log in
In general, I figured it out without the help of the community!
Everything turned out to be simple, the LOAD_FAST, LOAD_ATTR, LOAD_CONST instructions simply load references to the necessary objects and only the CALL_FUNCTION instruction changes the data - therefore the whole operation is atomic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question