[Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin

David Mertz mertz at gnosis.cx
Thu Apr 5 19:20:56 EDT 2018


On Thu, Apr 5, 2018, 5:32 PM Peter O'Connor <peter.ed.oconnor at gmail.com>
wrote:

> I find this a bit awkward, and maintain that it would be nice to have this
> as a built-in language construct to do this natively.  You have to admit:
>
>     smooth_signal = [average = (1-decay)*average + decay*x for x in signal
> from average=0.]
>
> Is a lot cleaner and more intuitive than:
>
>     dev compute_avg(avg, x):
>         return (1 - decay)*avg + decay * x
>

The proposed syntax strikes me as confusing and mysterious to do something
I do only occasionally.  In contrast, itertools.accumulate() is
straightforward and far more general.

Definitely -100 on the proposal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180405/dc3a728d/attachment.html>


More information about the Python-ideas mailing list