Tim Peters <t...@python.org> added the comment:
Hi. "It's pretty good for a lot of things" is precisely what I'm questioning. Name some, and please be specific ;-) Tree reduction is very popular in the parallel processing world, for obvious reasons. But we're talking about a single thread here, and there aren't all that many associative binary operators (or, depending on implementation, they may need also to be commutative). I gave floating * as an example: tree reduction buys nothing for accuracy, and would be both slower and consume more memory. Other associative operators for which all the same are true include bitwise &, bitwise |, bitwise ^, min, and max. Floating + can benefit for accuracy, but we already have math.fsum() for that, which delivers the most accurate possible result. The only unaddressed example we have here so far that could actually benefit is bigint *. If that's the real use case, fine, but there are better ways to address that case. I've searched in vain for other languages that try to address this "in general", except in the context of parallelization. As Guido will tell you, the only original idea in Python is adding an "else" clause to loops ;-) In any case, I don't believe this belongs hiding in reduce(). As above, it's a net loss for most binary operators. Too close to "attractive nuisance" territory. Adding a new, e.g., treereduce() would be better - provided that it is in fact "pretty good for a lot of things". ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46868> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com