Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 4.3.0
-
None
-
ghx-label-5
Description
Python 3 made map, range, zip, and filter lazy. That means that existing Python code that relies on this turning into a list immediately need adjustments:
# Python 2: range(5) == [0,1,2,3,4] True # Python 3: range(5) == [0,1,2,3,4] False # Python 3 fix: list(range(5)) == [0,1,2,3,4] True # Same deal with map, zip, filter, etc.
This example is basic, but this applies across the board.
Since the ordinary operators like range, filter, etc are now lazy, the old lazy ones have been removed (xrange, ifilter, izip). Those need to be replaced, and the future package provides implementations of range, zip, map, filter, etc.
See:
https://python-future.org/compatible_idioms.html#xrange
https://python-future.org/compatible_idioms.html#range
https://python-future.org/compatible_idioms.html#map
https://python-future.org/compatible_idioms.html#imap
etc
This corresponds to these pylint checks:
xrange-builtin
range-builtin-not-iterating
map-builtin-not-iterating
zip-builtin-not-iterating
filter-builtin-not-iterating
reduce-builtin
deprecated-itertools-function
Futurize has some tools to help:
libfuturize.fixes.fix_xrange_with_import
lib2to3.fixes.fix_map
lib2to3.fixes.fix_filter