summaryrefslogtreecommitdiffstats
path: root/Lib/pstats.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-04-05 18:56:31 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-04-05 18:56:31 (GMT)
commitc50846aaef3e38d466ac9a0a87f72f09238e2061 (patch)
treef6ae48bcfbabb5107c971c240f3b06a549084f98 /Lib/pstats.py
parent5daab45158094e577b9791cda7d8a0f4e34f45cb (diff)
downloadcpython-c50846aaef3e38d466ac9a0a87f72f09238e2061.zip
cpython-c50846aaef3e38d466ac9a0a87f72f09238e2061.tar.gz
cpython-c50846aaef3e38d466ac9a0a87f72f09238e2061.tar.bz2
Forward port total_ordering() and cmp_to_key().
Diffstat (limited to 'Lib/pstats.py')
-rw-r--r--Lib/pstats.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/Lib/pstats.py b/Lib/pstats.py
index e2fee37..14c4606 100644
--- a/Lib/pstats.py
+++ b/Lib/pstats.py
@@ -37,6 +37,7 @@ import os
import time
import marshal
import re
+from functools import cmp_to_key
__all__ = ["Stats"]
@@ -226,7 +227,7 @@ class Stats:
stats_list.append((cc, nc, tt, ct) + func +
(func_std_string(func), func))
- stats_list.sort(key=CmpToKey(TupleComp(sort_tuple).compare))
+ stats_list.sort(key=cmp_to_key(TupleComp(sort_tuple).compare))
self.fcn_list = fcn_list = []
for tuple in stats_list:
@@ -458,15 +459,6 @@ 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)