From 695716efb0f79f9a0e716952b1dcd433d866371a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 18 Aug 2017 18:43:46 +0200 Subject: [FIX] P3: remove pycompat.{keys,items,values} helpers Now that we're closer to switching to P3 for good, these helpers have outlived their usefulness, and mostly add noise. All remaining dict.iter*() or dict.view*() must be converted to the normal keys(), values() or items() calls. Whenever the result is likely to be used for more than the scope of a loop, or when the dict needs to be modified during iteration, the calls must be wrapped in a ``list()``, to protect the new P3 semantics. Those cases are very exceptional. Also removed some dead code or improved the API to remove unnecessary conversions. --- doc/python3.rst | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'doc/python3.rst') diff --git a/doc/python3.rst b/doc/python3.rst index 7ca86708ced..c8e8269936e 100644 --- a/doc/python3.rst +++ b/doc/python3.rst @@ -233,10 +233,7 @@ methods or functions having been *removed entirely*: .. important:: When possible, use comprehensions (list, generator, ...) rather than - ``map`` or ``filter``, otherwise use the cross-version ``pycompat`` - versions (``pycompat.imap``, ``pycompat.ifilter`` and - ``pycompat.izip``). The ``pycompat`` versions all return *iterators* and - may need to be wrapped in a ``list()`` call to yield a list. + ``map`` or ``filter``. * In Python 3, ``dict.keys``, ``dict.values`` and ``dict.items`` return *views* rather than lists, and the ``iter*`` and ``view*`` methods have @@ -244,11 +241,9 @@ methods or functions having been *removed entirely*: .. important:: - Prefer using :func:`odoo.tools.pycompat.keys`, - :func:`odoo.tools.pycompat.values` and :func:`odoo.tools.pycompat.items` - return cross-version iterators. When needing actual lists (e.g. to - modify a dictionary during iteration), wrap one of the calls above in a - ``list()``. + When the result of the above methods is used for more than a one-shot + loop (e.g. to be included in returned value), or when the dict needs + to be modified during iteration, wrap the calls in a ``list()``. builtins -------- -- cgit v1.2.3