From: Andreas Sandberg Date: Sat, 26 Jan 2019 09:55:35 +0000 (+0000) Subject: python: Switch from using compare to key in list sort X-Git-Tag: v19.0.0.0~1138 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac00ec10ca483a3b96349dd2952a7881c6d8b29a;p=gem5.git python: Switch from using compare to key in list sort Python 3 has deprecated the use of a comparison function in favour of a key extraction function. Change-Id: I4b7eab791ecbdfbf7147f57fdbc7cbe8f1de20dd Signed-off-by: Andreas Sandberg Reviewed-on: https://gem5-review.googlesource.com/c/15995 Reviewed-by: Gabe Black Reviewed-by: Giacomo Travaglini --- diff --git a/src/python/m5/stats/__init__.py b/src/python/m5/stats/__init__.py index ba91f22c7..acb62f13e 100644 --- a/src/python/m5/stats/__init__.py +++ b/src/python/m5/stats/__init__.py @@ -169,12 +169,7 @@ def enable(): if not (stat.flags & flags.display): stat.name = "__Stat%06d" % stat.id - def less(stat1, stat2): - v1 = stat1.name.split('.') - v2 = stat2.name.split('.') - return v1 < v2 - - stats_list.sort(less) + stats_list.sort(key=lambda s: s.name.split('.')) for stat in stats_list: stats_dict[stat.name] = stat stat.enable()