Josh Rosenberg <shadowranger+pyt...@gmail.com> added the comment:

I believe Tim Peters's concern with:

    Set1 = Set1 & Set2

is misplaced, because he's drawn an analogy with the string concatenation 
optimization, which *does* handle:

    Str1 = Str1 + Str2

because the optimization is in the ceval loop and can check the subsequent 
instruction for a "simple store", clearing the target's reference if the target 
and the left operand are the same thing. This change doesn't try to handle this 
case, so the only time the optimization takes place is when the only reference 
to the left hand operand is on the stack (not in any named variable at all).

Tim's concern *would* make it unsafe to extend this patch to apply the target 
clearing optimization, because at global scope, clearing the target would be 
observable from __hash__/__eq__ (and from other threads); str is safe because 
it holds the GIL the whole time, and can't invoke arbitrary Python level code 
that might release it, set doesn't have that guarantee.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36229>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to