[Python-Dev] Rationale for sum()'s design?

Alex Martelli aleaxit at yahoo.com
Mon Mar 14 13:12:59 CET 2005


On Mar 14, 2005, at 11:20, Nick Coghlan wrote:
    ...
> Somewhat ugly, but backwards compatible:

I realize you're mostly talking semantics, not implementation, but, as 
long as we're at it, could we pretty please have back the optimization 
indicated by...:

>   # Add the elements

    if isinstance(value, basestring):
       return value + ''.join(itr)

>   for item in itr:
>     value += item
>   return value

...?  This doesn't break bw compat since currently when value's a 
string sum would raise an exception...


Alex



More information about the Python-Dev mailing list