[New-bugs-announce] [issue32321] functools.reduce has a redundant guard or needs a pure Python fallback

Steven D'Aprano report at bugs.python.org
Thu Dec 14 08:26:34 EST 2017


New submission from Steven D'Aprano <steve+python at pearwood.info>:

The functools module imports reduce from _functools, using a guard in case it is not present:

try:
    from _functools import reduce
except ImportError:
    pass


However, the documentation says nothing about reduce being optional, and it is unconditionally included in the module __all__.

If reduce is guaranteed to be implemented in _functools, then the guard is redundant and should be removed. Otherwise, a pure python fallback should be added.

(The docs for reduce include a pure Python equivalent which might be sufficient.)

----------
components: Library (Lib)
keywords: easy
messages: 308297
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: functools.reduce has a redundant guard or needs a pure Python fallback
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32321>
_______________________________________


More information about the New-bugs-announce mailing list