diff options
| author | Xavier Morel <xmo@odoo.com> | 2017-04-12 09:53:33 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2017-04-12 13:48:42 +0200 |
| commit | 76852a2fad05292b8d592b76b37e4732f9c60a2d (patch) | |
| tree | 89f532e4d594b815b98f0425397b6156888626c3 /doc | |
| parent | 15e17e7b48f89f6e897a28f5031cdd740a887d80 (diff) | |
[#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
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/python3.rst | 15 |
1 files changed, 15 insertions, 0 deletions
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 ----------------------- |
