diff options
author | Raymond Hettinger <python@rcn.com> | 2008-01-30 20:15:17 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-01-30 20:15:17 (GMT) |
commit | 70b64fce96e894dfa8af5afd1f8b3fe863ba16e0 (patch) | |
tree | 15d549753edea1f11c0a3990ea0419426220c445 /Lib/pstats.py | |
parent | 4f066126d616d35aa8c0911a915ad64a09aaf16e (diff) | |
download | cpython-70b64fce96e894dfa8af5afd1f8b3fe863ba16e0.zip cpython-70b64fce96e894dfa8af5afd1f8b3fe863ba16e0.tar.gz cpython-70b64fce96e894dfa8af5afd1f8b3fe863ba16e0.tar.bz2 |
Issue #1771: Remove cmp parameter from list.sort() and builtin.sorted().
Diffstat (limited to 'Lib/pstats.py')
-rw-r--r-- | Lib/pstats.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/pstats.py b/Lib/pstats.py index 39f1b64..3e6e994 100644 --- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -238,7 +238,7 @@ class Stats: stats_list.append((cc, nc, tt, ct) + func + (func_std_string(func), func)) - stats_list.sort(TupleComp(sort_tuple).compare) + stats_list.sort(key=CmpToKey(TupleComp(sort_tuple).compare)) self.fcn_list = fcn_list = [] for tuple in stats_list: @@ -470,6 +470,16 @@ class TupleComp: return direction return 0 +def CmpToKey(mycmp): + 'Convert a cmp= function into a key= function' + class K(object): + def __init__(self, obj): + self.obj = obj + def __lt__(self, other): + return mycmp(self.obj, other.obj) == -1 + return K + + #************************************************************************** # func_name is a triple (file:string, line:int, name:string) |