Thread safetyness in Python

John Baxter jwbaxter at spamcop.net
Wed Jul 3 18:42:38 EDT 2002


In article <mailman.1025709845.26970.python-list at python.org>,
 "Tim Peters" <tim at zope.com> wrote:

> Do a reality check before relying on this.  I don't know of any platform
> where C compiles a++ to atomic code, even assuming a is of integral type.

And even if one finds such a platform, beware of builds with 
optimization turned off.  (With optimization turned on, of course, the 
a++ may vanish entirely if the result is used not used and a is not used 
later, which can be "disconcerting".)

(Although it's not possible to turn all code mashing off in many cases:  
it's common to compile as if the machine had an infinite supply of 
registers and then deal with the reality in a fixup operation.)

  --John--whose boss once wondered why his compiled code was putting 0 
into a memory cell, then reading out the cell and checking whether it 
was 0...a clear result of
   if (a = 0) ...



More information about the Python-list mailing list