[Python-ideas] Add nullifier argument to functools.reduce?

Devin Jeanpierre jeanpierreda at gmail.com
Sat Aug 23 18:15:02 CEST 2014


On Sat, Aug 23, 2014 at 9:01 AM, Joshua Landau <joshua at landau.ws> wrote:
> A better answer in my opinion would be something more like
> "reduce(..., stop_on=sentinel)". This could even allow more
> optimisations than your idea:
>
>     reduce(operator.mul, iterable, stop_on=0)
>     reduce(operator.add, iterable, stop_on=float("nan"))
>
> etc.

How is this any different?

-- Devin


More information about the Python-ideas mailing list