summaryrefslogtreecommitdiff
path: root/doc/python3.rst
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2017-08-18 18:43:46 +0200
committerOlivier Dony <odo@openerp.com>2017-08-20 23:25:54 +0200
commit695716efb0f79f9a0e716952b1dcd433d866371a (patch)
tree1b582a3469d12fc716d6252b4f239f0cd40da9e4 /doc/python3.rst
parent589c0d7e2c3a44adc5d26aac8af08c0d06b97d5a (diff)
[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.
Diffstat (limited to 'doc/python3.rst')
-rw-r--r--doc/python3.rst13
1 files changed, 4 insertions, 9 deletions
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
--------