A query about list

Alex Martelli aleaxit at yahoo.com
Sat Oct 11 14:22:33 EDT 2003


Dave Benjamin wrote:
   ...
> Normally, I'd suggest "reduce(operator.add, ...)" to flatten a list, but

It would be an utter waste anyway, in Python 2.3.  The sum() builtin
is quite a bit faster, as well as obviously simpler.

> since you've got some "naked" entries, that won't work...

Yeah, there's the rub, of course.  But I don't think I have anything
to add to the many ideas you and others have proposed on this;
just wanted to point out sum's existence and preferability;-).


Alex





More information about the Python-list mailing list