From 76852a2fad05292b8d592b76b37e4732f9c60a2d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 12 Apr 2017 09:53:33 +0200 Subject: [#8530] fix uses of ``reduce`` builtin Demoted to library in Python 3, see if uses can be replaced by more specific construct, just import functools.reduce otherwise. Futurize fixers: * lib2to3.fixes.fix_reduce --- doc/python3.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'doc/python3.rst') diff --git a/doc/python3.rst b/doc/python3.rst index 4506fb9d9f1..cb60965eb6c 100644 --- a/doc/python3.rst +++ b/doc/python3.rst @@ -99,6 +99,21 @@ Removed Operators These two operators were long recommended against/deprecated in Python 2, Python 3 removed them from the language. +Removed/renamed builtins +------------------------ + +``reduce`` +########## + +In Python 3, ``reduce`` has been demoted from builtin to ``functools.reduce``. +However this is because many (if not most) uses of ``reduce`` can be replaced +by ``sum``, ``all``, ``any`` or a list comprehension for a more readable and +faster result. + +It is easy enough to just add ``from functools import reduce`` to the file +and compatible with Python 2.6 and later, but consider whether you get better +code by replacing it with some other method altogether. + Removed/renamed methods ----------------------- -- cgit v1.2.3