Steven D'Aprano wrote: >But I think it is a shame that sum() does a > special type-check to avoid something which is only sometimes slow. It > doesn't protect against O(n**2) performance; it merely protects against > just one of an infinite number of possible "traps for the unwary".
I'm not so sure special casing was a good idea myself, but... If you allow for a small number of special cases in the language to protect against the most harmful and prone traps, this case would be one of the top ones, IMHO. Carl Banks and, you know, if you really want to concatenate strings with sum, you can class noopadd(object): def __add__(self,other): return other sum(["abc","def","ghi"],noopadd()) -- http://mail.python.org/mailman/listinfo/python-list