comparison mercurial/lsprof.py @ 9032:1fa80c5428b8

compat: use 'key' argument instead of 'cmp' when sorting a list
author Alejandro Santos <alejolp@alejolp.com>
date Sun, 05 Jul 2009 11:02:00 +0200
parents 553aa0cbeab6
children 23cf7b52785a
comparison
equal deleted inserted replaced
9031:3b76321aa0de 9032:1fa80c5428b8
24 24
25 def sort(self, crit="inlinetime"): 25 def sort(self, crit="inlinetime"):
26 """XXX docstring""" 26 """XXX docstring"""
27 if crit not in profiler_entry.__dict__: 27 if crit not in profiler_entry.__dict__:
28 raise ValueError("Can't sort by %s" % crit) 28 raise ValueError("Can't sort by %s" % crit)
29 self.data.sort(lambda b, a: cmp(getattr(a, crit), 29 self.data.sort(key=lambda x: getattr(x, crit), reverse=True)
30 getattr(b, crit)))
31 for e in self.data: 30 for e in self.data:
32 if e.calls: 31 if e.calls:
33 e.calls.sort(lambda b, a: cmp(getattr(a, crit), 32 e.calls.sort(key=lambda x: getattr(x, crit), reverse=True)
34 getattr(b, crit)))
35 33
36 def pprint(self, top=None, file=None, limit=None, climit=None): 34 def pprint(self, top=None, file=None, limit=None, climit=None):
37 """XXX docstring""" 35 """XXX docstring"""
38 if file is None: 36 if file is None:
39 file = sys.stdout 37 file = sys.stdout