Hacker Newsnew | past | comments | ask | show | jobs | submit | bjourne's commentslogin


You are 100% right but I think your arguments will fall on deaf ears. Someone bribed Trump or one of his cronies to revoke pollution limits and they got it. What to do when rationality just isn't a factor in politics anymore?

Call me crazy... but there's something about their faces. Almost like all of them are brothers and sisters. Creepy in a way.

It's because it reduces data dimensionality. From 2d to 1d and from 1d to 0d (scalar).

But that's not actually guaranteed at all.

You "accumulate" an answer one item at a time, but there's no guarantee any dimensions are getting reduced.

You can easily duplicate the effects of map with reduce, for example, so the dims would stay the same. You could even expand dimensions, if you like, turning a 1-d array with n elements into an s X t 2-d array. If the reducing function tracks the total number of elements seen, it can easily know when to start a new row.

This is part of why people keep pointing out the name, "reduce", is a bit misleading.


It always messes with me: reducing across a specific axis always takes O(whole tensor) time, because there's no difference between "iterate over all dims, then collapse the final one" versus "iterate versus the first dim and do some cursed tensor accum" (and likewise for between)

Maybe there's just a better way to think about it and I'm still thinking about it way too much like a programmer


No, reduce has exactly the same time complexity as map and filter.

Sorry I changed problems a bit and started talking about me trying to understand matrices lol

Maybe you are misremembering the story? += deferred concatenation requires lazy strings and that didn't come until 10-15 years later. However, concatenating string lists with sum() was a common Python idiom at the time and it indeed incurred O(n^2) complexity. Gvr's reduce dislike was more about its syntax. It doesn't mesh well with Python's lambda syntax.

> += deferred concatenation requires lazy strings and that didn't come until 10-15 years later.

CPython's += does not perform deferred concatenation and CPython does not use lazy strings. The optimization uses an eager in-place realloc if the string's ref-count is 1. This remains the optimization used even to this day and was introduced in 2005:

https://docs.python.org/3/whatsnew/2.4.html#optimizations

>However, concatenating string lists with sum() was a common Python idiom at the time

It could not possibly have been a common Python idiom since sum() explicitly rejected strings by throwing a TypeError. This was explicitly special cased to avoid the degenerate performance and the TypeError even has an error message saying "TypeError: sum() can't sum strings [use ''.join(seq) instead]".

>Gvr's reduce dislike was more about its syntax. It doesn't mesh well with Python's lambda syntax.

No it had nothing to do with mixing with lambda syntax, on the contrary GvR actually wanted to remove reduce and lambda (and map and filter as well). Here is the actual article by GvR regarding removing reduce, absolutely nothing in it involves how it mixes with lambda expressions.

https://www.artima.com/weblogs/viewpost.jsp?thread=98196

>So now reduce(). This is actually the one I've always hated most, because, apart from a few examples involving + or *, almost every time I see a reduce() call with a non-trivial function argument, I need to grab pen and paper to diagram what's actually being fed into that function before I understand what the reduce() is supposed to do. So in my mind, the applicability of reduce() is pretty much limited to associative operators, and in all other cases it's better to write out the accumulation loop explicitly.


Yes thanks for finding the Python 2.4 release page which shows the optimization! So I remembered correctly -- Python already had that optimization back then. (There seems to be a large amount of confusion on that in this subthread)

And the March 2005 Artima post is also a very good reference! That actually predates my story, since Guido hadn't joined Google by then. I recall that he joined in December 2005.

So maybe the bug I remember was more of a "push" in the direction he had already thought of, not the direct inspiration.

It's clear from the blog post that he disliked all of map / filter / reduce, and then I'm sure that users or python-dev pushed back on removing them, so he settled for banishing reduce() to the stdlib.



Free, usable, non-toxic, decentralized social media.

Isn't the sex => baby causation well known even among monkeys?

Shutting down => Not building new ones. All decommissioned reactors would have reached EOL by 2025 anyhow.

Power generation is 25% higher with 6 than with 12 reactors. Plenty of scaremongering around volatility, though. Consumers don't realize that one-hour price spikes are completely irrelevant since they pay monthly (or even quarterly) AVERAGE prices. Max, min, mean, and standard deviation. People don't know statistics and are so easy to fool by demagogues.

Large customers buy directly on electricity markets at hourly market price, or have direct power purchase agreements with power suppliers.

Most small customers are paying using average prices, but these average prices are calculated from the costs of power suppliers and these are affected by hourly market prices. So when many small customers consume use lot of electricity during hours with high hourly market price, the average price for small customers goes up.

Best solution is instalation of smart meters so that small customers pay according to hourly market price.


The bottleneck is the grid, not the production centers. Volatility is not more extreme in Sweden than other connected (Nord Pool) countries. Companies lament the lack of grid connectivity all the time. Then they get the offer "Pay for the cost of grid expansion to connect you" and they are not so interested anymore.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: