<div dir="ltr">The string concat optimization happens in the interpreter dispatch for INPLACE_ADD<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 1, 2017 at 9:10 PM, Greg Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Chris Angelico wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This particular example is safe, because the arguments get passed<br>
individually - so 'args' has one reference, plus there's one more for<br>
the actual function call<br>
</blockquote>
<br></span>
However, that's also true when you use the += operator,<br>
so if the optimisation is to trigger at all in any useful<br>
case, the refcount threshold needs to be set higher than<br>
1.<br>
<br>
Some experiments I did suggest that if you set it high<br>
enough for x += y to trigger it, then it will also be<br>
triggered in Joe's case.<br>
<br>
BTW, isn't there already a similar optimisation somewhere<br>
for concatenating strings? Does it still exist? How does<br>
it avoid this issue?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Greg</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/joe%40quantopian.com" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/options/python-dev/joe%<wbr>40quantopian.com</a><br>
</div></div></blockquote></div><br></div>