<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 1, 2017 at 6:16 PM, Joe Jevnik via Python-Dev <span dir="ltr"><<a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The string concat optimization happens in the interpreter dispatch for INPLACE_ADD<br></div></blockquote><div><br></div><div>In that case, isn't there a new string being build, all in one line of python? that is, the string the optimization is being created at that point, so the interpreter can know there isn't anything referencing it anywhere else.</div><div><br></div><div>-CHB</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><br><div class="gmail_quote"><span class="">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></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><span>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="m_-8271137844320240341HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Greg</font></span></span><div class="m_-8271137844320240341HOEnZb"><div class="m_-8271137844320240341h5"><span class=""><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></span>
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%40qua<wbr>ntopian.com</a><br>
</div></div></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>chris.barker%40noaa.gov</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>