Critical sections and mutexes
Skip Montanaro
skip at pobox.com
Wed Oct 24 15:37:40 EDT 2001
dave> P.S. - Print statements are not atomic and do not fall in the same
dave> realm as "normal" Python operations (e.g. "i = 5") ...
Assignment is not atomic either. Your example would byte compile to
LOAD_CONST 5
STORE_FAST i
As others have mentioned, at the level of individual opcodes Python is
atomic. The statement
i = j
would have to be protected if j could be rebound or the object j referenced
could be modified by another thread.
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
More information about the Python-list
mailing list