You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2023/03/09 17:23:00 UTC

[jira] [Commented] (IMPALA-11975) Fix dictionary methods that became lazy

    [ https://issues.apache.org/jira/browse/IMPALA-11975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698507#comment-17698507 ] 

ASF subversion and git services commented on IMPALA-11975:
----------------------------------------------------------

Commit c233634d747e4106128627f258d1bee23855fd1e in impala's branch refs/heads/master from Joe McDonnell
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=c233634d7 ]

IMPALA-11975: Fix Dictionary methods to work with Python 3

Python 3 made the main dictionary methods lazy (items(),
keys(), values()). This means that code that uses those
methods may need to wrap the call in list() to get a
list immediately. Python 3 also removed the old iter*
lazy variants.

This changes all locations to use Python 3 dictionary
methods and wraps calls with list() appropriately.
This also changes all itemitems(), itervalues(), iterkeys()
locations to items(), values(), keys(), etc. Python 2
will not use the lazy implementation of these, so there
is a theoretical performance impact. Our python code is
mostly for tests and the performance impact is minimal.
Python 2 will be deprecated when Python 3 is functional.

This addresses these pylint warnings:
dict-iter-method
dict-keys-not-iterating
dict-values-not-iterating

Testing:
 - Ran core tests

Change-Id: Ie873ece54a633a8a95ed4600b1df4be7542348da
Reviewed-on: http://gerrit.cloudera.org:8080/19590
Reviewed-by: Joe McDonnell <jo...@cloudera.com>
Tested-by: Joe McDonnell <jo...@cloudera.com>


> Fix dictionary methods that became lazy
> ---------------------------------------
>
>                 Key: IMPALA-11975
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11975
>             Project: IMPALA
>          Issue Type: Sub-task
>          Components: Infrastructure
>    Affects Versions: Impala 4.3.0
>            Reporter: Joe McDonnell
>            Priority: Major
>
> Dictionary methods like items, keys, values became lazy, similar to the other list functions. Existing code that relies on these methods producing lists immediately need to wrap the call in list(). The old iter* methods have been removed, so that code needs to be fixed up.
> See: [https://python-future.org/compatible_idioms.html#dictionaries]
> Replacing the iter* methods with the non-iter equivalent works fine in Python 3 (e.g. iteritems() becomes items()), but it is less efficient on Python 2. This is annoying, but since our Python code is not very performance sensitive and our intention is to remove Python 2, it doesn't seem useful to do complicated things to avoid it.
> This corresponds to these Pylint checks:
> dict-iter-method
> dict-keys-not-iterating
> dict-values-not-iterating



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org