On Thu, Aug 21, 2008 at 12:22 PM, Ian Kelly <[EMAIL PROTECTED]> wrote:
>
> On Thu, Aug 21, 2008 at 10:00 AM, Waylan Limberg <[EMAIL PROTECTED]> wrote:
>> I had thought that I read from that same source that formatting is
>> faster than concatenation (and that's why I checked there before
>> responding), but I don't see that mentioned. Not sure where I got that
>> idea or if its even true.
>
> Formatting is faster than serial concatenation, which often results in
> copying the same substring multiple times.  A single concatenation is
> usually faster than formatting, however.
>

PEP 8 has something to say about this under "Programming Recommendations":

    - Code should be written in a way that does not disadvantage other
      implementations of Python (PyPy, Jython, IronPython, Pyrex, Psyco,
      and such).

      For example, do not rely on CPython's efficient implementation of
      in-place string concatenation for statements in the form a+=b or a=a+b.
      Those statements run more slowly in Jython.  In performance sensitive
      parts of the library, the ''.join() form should be used instead.  This
      will ensure that concatenation occurs in linear time across various
      implementations.

Of course, this doesn't say anything about formatting - just joins,
but concatenation seems to be generally discouraged wherever we look.




-- 
----
Waylan Limberg
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to