Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c3ce0e53
Commit
c3ce0e53
authored
Aug 03, 2008
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Silence -3 warnings in pstats: a dict.has_key() usage and backport solution to
move from list.sort(cmp=) to key=.
parent
cc2f7b49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
Lib/pstats.py
Lib/pstats.py
+12
-2
No files found.
Lib/pstats.py
View file @
c3ce0e53
...
...
@@ -140,7 +140,7 @@ class Stats:
self
.
total_calls
+=
nc
self
.
prim_calls
+=
cc
self
.
total_tt
+=
tt
if
callers
.
has_key
((
"jprofile"
,
0
,
"profiler"
))
:
if
(
"jprofile"
,
0
,
"profiler"
)
in
callers
:
self
.
top_level
[
func
]
=
None
if
len
(
func_std_string
(
func
))
>
self
.
max_name_len
:
self
.
max_name_len
=
len
(
func_std_string
(
func
))
...
...
@@ -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
:
...
...
@@ -471,6 +471,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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment