Author: serge_sans_paille Date: Tue Dec 18 00:38:50 2018 New Revision: 349455
URL: http://llvm.org/viewvc/llvm-project?rev=349455&view=rev Log: Portable Python script across Python version In Python2, division between integer yields an integer, while it yields a float in Python3. Use a combination of from __future__ import division and // operator to get a portable behavior. Differential Revision: https://reviews.llvm.org/D55204 Modified: cfe/trunk/utils/ABITest/TypeGen.py cfe/trunk/utils/analyzer/CmpRuns.py Modified: cfe/trunk/utils/ABITest/TypeGen.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=349455&r1=349454&r2=349455&view=diff ============================================================================== --- cfe/trunk/utils/ABITest/TypeGen.py (original) +++ cfe/trunk/utils/ABITest/TypeGen.py Tue Dec 18 00:38:50 2018 @@ -1,5 +1,5 @@ """Flexible enumeration of C types.""" -from __future__ import print_function +from __future__ import division, print_function from Enumeration import * @@ -235,7 +235,7 @@ def fact(n): # Compute the number of combinations (n choose k) def num_combinations(n, k): - return fact(n) / (fact(k) * fact(n - k)) + return fact(n) // (fact(k) * fact(n - k)) # Enumerate the combinations choosing k elements from the list of values def combinations(values, k): Modified: cfe/trunk/utils/analyzer/CmpRuns.py URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=349455&r1=349454&r2=349455&view=diff ============================================================================== --- cfe/trunk/utils/analyzer/CmpRuns.py (original) +++ cfe/trunk/utils/analyzer/CmpRuns.py Tue Dec 18 00:38:50 2018 @@ -25,7 +25,7 @@ Usage: diff = compareResults(resultsA, resultsB) """ -from __future__ import print_function +from __future__ import division, print_function from collections import defaultdict @@ -308,7 +308,7 @@ def deriveStats(results): "mean": sum(values) / len(values), "90th %tile": computePercentile(values, 0.9), "95th %tile": computePercentile(values, 0.95), - "median": sorted(values)[len(values) / 2], + "median": sorted(values)[len(values) // 2], "total": sum(values) } return combined_stats _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits