Python, Erlang, Map/Reduce

Welcome, Tom.

The typical use case for Erlang (or for Hadoop, as you pointed) would be more like “do what Tim says in 500 machines and aggregate the results”. I skimmed on your comment, now I went to the real paper. When I said missing I meant mostly Tim, and it was before his fifth post appeared.

The funny thing about the code is I was going to use the classic map and reduce functions, but I remembered that reduce is doomed, and reading Guido’s post I found:

filter(P, S) is almost always written clearer as [x for x in S if P(x)], and this has the huge advantage that the most common usages involve predicates that are comparisons, e.g. x==42, and defining a lambda for that just requires much more effort for the reader (plus the lambda is slower than the list comprehension). Even more so for map(F, S) which becomes [F(x) for x in S].

As an added benefit, the code is much more similar to Erlang’s comprehensions. Actually using [] will make them in-memory lists, but using () will turn them into generators.

Posted by Santiago Gala