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

Warren Weckesser warren.weckesser at gmail.com
Mon Aug 25 03:17:22 CEST 2014


On Sun, Aug 24, 2014 at 8:05 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Sun, Aug 24, 2014 at 2:27 AM, Warren Weckesser
> <warren.weckesser at gmail.com> wrote:
> > That wouldn't help in an example such as
> >
> >     reduce(lambda x, y: x & y, [{1,2}, {3, 4}, {5, 6}], nullifier={})
> >
> > The nullifier is the empty set, but the empty set does not occur in the
> > iterable.
>
> Caution: Your nullifier is an empty dict, not an empty set, if you
> spell it that way.
>


Ah, right--thanks!  It should be `nullifier=set()`.




>
> I think this is a cute concept, but not something that is going to be
> needed all that often. Most Python programs don't even use reduce() in
> its default form, much less need a specific optimization.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140824/9e41efe7/attachment-0001.html>


More information about the Python-ideas mailing list