From bd8d3419e1b6a1c7ec82e1ceb1f22b407a38dac9 Mon Sep 17 00:00:00 2001 From: Serge Guelton Date: Tue, 18 Dec 2018 16:04:21 +0000 Subject: Portable Python script across Python version In Python3, dict.items, dict.keys, dict.values, zip, map and filter no longer return lists, they create generator instead. The portability patch consists in forcing an extra `list` call if the result is actually used as a list. `map` are replaced by list comprehension and `filter` by filtered list comprehension. Differential Revision: https://reviews.llvm.org/D55197 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349501 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/perf-training/perf-helper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/perf-training') diff --git a/utils/perf-training/perf-helper.py b/utils/perf-training/perf-helper.py index 30b9caeffd..6337a9b19a 100644 --- a/utils/perf-training/perf-helper.py +++ b/utils/perf-training/perf-helper.py @@ -295,8 +295,8 @@ def form_by_frequency(symbol_lists): for a in symbols: counts[a] = counts.get(a,0) + 1 - by_count = counts.items() - by_count.sort(key = lambda (_,n): -n) + by_count = list(counts.items()) + by_count.sort(key = lambda __n: -__n[1]) return [s for s,n in by_count] def form_by_random(symbol_lists): @@ -333,7 +333,7 @@ def genOrderFile(args): help="write a list of the unordered symbols to PATH (requires --binary)", default=None, metavar="PATH") parser.add_argument("--method", dest="method", - help="order file generation method to use", choices=methods.keys(), + help="order file generation method to use", choices=list(methods.keys()), default='call_order') opts = parser.parse_args(args) -- cgit v1.2.1