Search code examples
pythonpython-2.xfunctools

How are Python2's built-in reduce and functools.reduce different?


Both have exact same documentation, and it seems to me that both stem from same source code in https://hg.python.org/cpython/file/Modules/_functoolsmodule.c.

However, I am not sure about it. I didn't find any other refernces in the source code of CPython. Can some one shed some more light on this here?


Solution

  • Per the documentation of functools.reduce in Python 2:

    This is the same function as reduce(). It is made available in this module to allow writing code more forward-compatible with Python 3.