Peter Astrand wrote:
Personally, I think Python has too many builtins already.

A suggestion was made on c.l.p a while back to have a specific module dedicated to reductive operations. That is, just as itertools is oriented towards manipulating iterables and creating iterators, this module would be oriented towards consuming iterators in a reductive fashion.


product(), anytrue() and alltrue() were obvious candidates for inclusion ([1]).

The combination of explicit for loops and a standard toolkit of reductive operations was designed to eliminate the need for reduce() ([2]).

Cheers,
Nick.

[1] While any()/all() read well in the context of an if statement, I think anytrue()/alltrue() better convey the reductive nature of the operations, read nearly as well in the if context, and read significantly better when isolated from the if context (e.g. assigned to a variable). I also think the names are less likely to collide with existing variable names.

[2] I'm firmly in Guido's camp on this one - whenever I encounter code that uses reduce(), I have to rewrite it (either mentally or literally) to use a for loop before I can understand it. Getting rid of the function would benefit me because I would no longer have to waste time figuring out what such code was doing - it would already be an explicit loop, or it would be using one of the standard reductive operations.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to