[Python-Dev] Re: accumulator display syntax

Guido van Rossum guido at python.org
Sat Oct 25 19:16:35 EDT 2003


> > No way.  There's nothing that guarantees that a+=b has the same
> > semantics as a+b, and in fact for lists it doesn't.
> 
> You mean because += is more permissive (accepts any sequence
> RHS while + insists the RHS be specifically a list)?  I don't see how
> this would make it bad to use += instead of + -- if we let the user
> sum up a mix of (e.g.) strings and tuples, why are we hurting him?

We specifically decided that sum() wasn't allowed for strings, because
it's a quadratic algorithm.  Other sequences are just as bad, we just
didn't expect that to be a common case.

Also see my not-so-far-fetched example of a semantic change.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list