In article <firstname.lastname@example.org>,
Stefan Franke <email@example.com> wrote: >
>What about augmented assignments of other built-in types? Being able
>to thread-safely append to a string buffer (or other sequences) with +=
>would be a big advantage of the somewhat infamous augmented assignment
>operators in my eyes.
Using the dis module, we see that the only difference between "x+='b'"
and "x=x+'b'" lies in substituting INPLACE_ADD for BINARY_ADD. If the
latter is thread-safe, so is the former; I'm not entirely confident
enough in my byte-code skills to make an assertion. But it looks to me
that it's not thread-safe because you're reading and assigning the same
variable in the same statement.
I *do* know that x.append('b') is a thread-safe operation -- and that's
probably a better bet, anyway, even if threading isn't involved.
--- Aahz (Copyright 2001 by firstname.lastname@example.org)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6
Nostalgia just ain't what it used to be