[Python-Dev] PEP 203 Augmented Assignment

Guido van Rossum guido@beopen.com
Thu, 27 Jul 2000 01:11:28 -0500

I should add something about the assumed pseudo thread-safety of a+=b.

I think this assumption is bogus, since we have to load a, do some
stuff, and then store a, and we can't guarantee that the stuff we do
is atomic -- in face we *know* it's not if it involves a user-defined

Simply put:

    a += 1 IS NOT ATOMIC!

Note that C doesn't guarantee that a++ is atomic either, even if a is
declared volatile.  (I believe there's an atomic data type, but I
don't think it guarantees atomic ++.  That would be very expensive
because the VM cache would have to be flushed on multiprocessor
machines.  The only docs I found are at

--Guido van Rossum (home page: http://www.pythonlabs.com/~guido/)