On Sun, Nov 28, 2021 at 10:52:03AM -0800, Christopher Barker wrote:

> Back in the day Python had map, filter, and reduce.

And still does :-)

> Then comprehensions were added, which are another way to express map and
> filter in one go.
> 
> I really like comprehensions.
> 
> But since then, there has been an informal movement, if you can call it
> that, back to map and filter.

I don't think there is a movement as such, I think that in the 
excitement of comprehensions, people rejected "confusing" functional 
idioms like map and filter and especially reduce (which got relegated 
from a builtin to a function in functools). But as comprehensions 
became commonplace and boring, and more people became aware of 
functional idioms from other languages, we've become more comfortable 
with them.

Beside, map is often shorter:

    map(len, strings)
    (len(s) for s in strings)

and people like shorter code.


> Itertools is great, but it's not all that
> compatible with comprehensions :-(

That's an odd thing to say. itertools operates on pretty much any 
iterable, comprehensions are iterables. What do you think itertools is 
lacking when it comes to comprehensions?


> I'm a bit confused as to why comprehensions seem to have become
> second-class citizens myself.

I don't think they are.

> Granted, deeply nesting multiple comprehensions is pretty ugly, so a fluent
> interface to nesting transformations on iterables does have its appeal.

Indeed.


-- 
Steve
_______________________________________________
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/AWP5U23G2V43MRAF3FOXIZJXJGWTOV73/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to