[Chris Angelico <ros...@gmail.com>]
> ...
> For it to be accepted, you have to convince people - particularly,
> core devs - that it's of value. At the moment, I'm unconvinced, but on
> the other hand, all you're proposing is a default value for a
> currently-mandatory argument, so the bar isn't TOO high (it's not like
> you're proposing to create a new language keyword or anything!).

Except it's not that simple:

    def gen(hi):
        i = 0
        while i < hi:
            yield i
            i += 1

    from itertools import compress
    g = gen(12)
    print(list(filter(None, g)))
    g = gen(12)
    print(list(compress(g, g)))

Which displays:

    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    [0, 2, 4, 6, 8, 10]

The first is obviously intended, but the latter is what you get merely
by giving the same argument twice to `complress()`.

`compress()` can't materialize its argument(s) into a list (or tuple)
first, because it's intended to work fine with infinite sequences. It
could worm around that like so:under the covers:

    from itertools import tee
    g = gen(12)
    print(list(compress(*tee(g))))

but that's just bizarre ;-) And inefficient.

Or perhaps the `compress()` implementation could grow internal
conditionals to use a different algorithm if the second argument is
omitted. But that would be a major change to support something that's
already easily done in more than one more-than-less obvious way.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/NASMPTHASUZQTVJPWLL3Q2YVL4DHKCJH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to