Python2 的内置 reduce 和 functools.reduce 有何不同?
How are Python2's built-in reduce and functools.reduce different?
两者都有完全相同的文档,在我看来它们都源自 https://hg.python.org/cpython/file/Modules/_functoolsmodule.c.
中的相同源代码
但是,我不确定。我没有在 CPython 的源代码中找到任何其他引用。有人可以在这里进一步说明这一点吗?
根据 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.
两者都有完全相同的文档,在我看来它们都源自 https://hg.python.org/cpython/file/Modules/_functoolsmodule.c.
中的相同源代码但是,我不确定。我没有在 CPython 的源代码中找到任何其他引用。有人可以在这里进一步说明这一点吗?
根据 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.