Message337886
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. |
|
Date |
User |
Action |
Args |
2019-03-13 23:44:52 | josh.r | set | recipients:
+ josh.r, tim.peters, arigo, rhettinger, serhiy.storchaka, pablogsal, brandtbucher |
2019-03-13 23:44:52 | josh.r | set | messageid: <1552520692.48.0.873982851219.issue36229@roundup.psfhosted.org> |
2019-03-13 23:44:52 | josh.r | link | issue36229 messages |
2019-03-13 23:44:52 | josh.r | create | |
|