<span class="gmail_quote"></span>My statement wasn't clear enough.<br><br>Rendering occurs if the string being concatenated is already a concatenation object created by an earlier assignment. <br><br>In s = a + b + c + d + e + f , there would be rendering of the source string if it is already a concatenation.
<br><br>Here is an example that would make it clear:<br>a = "Value a ="<br>a += "anything" # creates a concatenation<br>c = a + b #This would cause rendering of a and then c will become concatenation between a and b.
<br>c += "Something"<br># This will not append to the concatenation object, but cause rendering of c and then it will create a concatenation between c and "Something", which will be assigned to c.<br>
<br>
Now if there are a series of assignments,<br>(1) s = c + "something" # causes rendering of c<br>(2) s += a # causes rendering of s and creates a new concatenation<br>(3) s += b # causes rendering of s and creates a new concatenation
<br>(4) s += c # causes rendering of s and creates a new concatenation<br>(5) print s # causes rendering of s<br><br>If there is list of strings created and then they are concatenated with +=, I would expect it to be slower because of the additional allocations involved in rendering.
<br><span class="sg"><br>-Chetan</span><div><span class="e" id="q_10e5c8a1df3891e6_2"><br><div><span class="gmail_quote">On 10/18/06, <b class="gmail_sendername">Kristján V. Jónsson</b> <<a href="mailto:kristjan@ccpgames.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
kristjan@ccpgames.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>Doesn't it end up in a call to PyString_Concat()?
That should return a PyStringConcatenationObject too, right?</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial" size="2"><span>K</span></font></div><br>
<blockquote style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div dir="ltr" align="left" lang="en-us">
<hr>
<br><br>Construct like s = a + b + c + d + e , where a, b etc. have been
assigned string values earlier will not benefit from the patch.
<br><br></div></blockquote></div>
</blockquote></div><br>
</span></div>