[Python-ideas] map, filter, reduce methods for generators
Jacek Pliszka
jacek.pliszka at gmail.com
Thu Apr 10 23:12:14 CEST 2014
Hi!
Sorry if someone has already talked about it (my simple search did not show
any results).
What do you think about adding map, flatmap, filter and reduce methods to
generator type ?
I must admit I've seen and I like Java 8 notation and I think it might be
more readable than Python way in a few occasions.
I would like to be able to write:
range(100).\
filter( f1 ).\
map( f2 ).\
filter( f3 ).\
map( f4 ).\
reduce(operator.add)
in addition to current Pythonic way of
reduce( operator.add, f4(x) for x in
( f2(y) for y in range(100) if f1(y))
if f3(x) )
Though longer - Java way seems to be a bit more readable as the notation
follows the data flow sequence.
Do you think it is worth a PEP?
BR,
Jacek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140410/51012d56/attachment.html>
More information about the Python-ideas
mailing list