5 ms·
I'm guessing it's the same reason it doesn't have a reduce function, Guido loves loops
by cerved 4y ago
I'm guessing it's the same reason it doesn't have a reduce function, Guido loves loops
- __alexs 4y agoYou what? https://docs.python.org/3/library/functools.html?highlight=reduce#functools.reduce https://docs.python.org/3/library/functools.html?highlight=r...
- phyrex 4y agoNo, he's right. It got 'demoted' from a core function to a footnote in a module. See also https://blog.finxter.com/about-guidos-fate-of-reduce-in-python-3000/ https://blog.finxter.com/about-guidos-fate-of-reduce-in-pyth...
- __alexs 4y agoNo he's wrong. Python the language and Python the standard library are not separate things.
- cerved 4y agono I'm right > 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. https://www.artima.com/weblogs/viewpost.jsp?thread=98196 https://www.artima.com/weblogs/viewpost.jsp?thread=98196
- coldtea 4y agoGrantparent is right. What you pointed to is in functools, a "functional" utility package in the stdlib, which has even more exotic stuff. But Python doesn't have a reduce function as a primitive, and Guido and co discourage such uses. So much so, that Python 2 did have, and it was explicitly removed.