[Python-ideas] itertools has starmap but no starreduce?

Nick Coghlan ncoghlan at gmail.com
Fri Feb 12 16:43:07 CET 2010


Andrey Fedorov wrote:
> Is that right, or am I missing something obvious?

How would starreduce differ from normal reduction?

The difference between map and starmap is that the former consumes the
iterable arguments immediately and produces a list, the latter produces
an iterator (and lazily consumes its input as values are retrieved from
the iterator).

There is no similar distinction to be made in the case of reduce: the
only relevant semantic is to consume the entire iterable and produce the
final output value.

If you're suggesting a new kind of iterator that provides a progress
report at each step through the source iterable, that isn't really
reduction anymore, so the starreduce name would be misleading.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------



More information about the Python-ideas mailing list