Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e0d4972a
Kaydet (Commit)
e0d4972a
authored
Haz 02, 2002
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Replaced .keys() with dictionary iterators
üst
1fab9ee0
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
50 deletions
+46
-50
copy.py
Lib/copy.py
+4
-4
filecmp.py
Lib/filecmp.py
+6
-6
inspect.py
Lib/inspect.py
+1
-1
mailcap.py
Lib/mailcap.py
+3
-3
profile.py
Lib/profile.py
+3
-4
pstats.py
Lib/pstats.py
+25
-28
pyclbr.py
Lib/pyclbr.py
+1
-1
rlcompleter.py
Lib/rlcompleter.py
+2
-2
symtable.py
Lib/symtable.py
+1
-1
No files found.
Lib/copy.py
Dosyayı görüntüle @
e0d4972a
...
@@ -234,8 +234,8 @@ d[types.TupleType] = _deepcopy_tuple
...
@@ -234,8 +234,8 @@ d[types.TupleType] = _deepcopy_tuple
def
_deepcopy_dict
(
x
,
memo
):
def
_deepcopy_dict
(
x
,
memo
):
y
=
{}
y
=
{}
memo
[
id
(
x
)]
=
y
memo
[
id
(
x
)]
=
y
for
key
in
x
.
key
s
():
for
key
,
value
in
x
.
iteritem
s
():
y
[
deepcopy
(
key
,
memo
)]
=
deepcopy
(
x
[
key
]
,
memo
)
y
[
deepcopy
(
key
,
memo
)]
=
deepcopy
(
value
,
memo
)
return
y
return
y
d
[
types
.
DictionaryType
]
=
_deepcopy_dict
d
[
types
.
DictionaryType
]
=
_deepcopy_dict
if
PyStringMap
is
not
None
:
if
PyStringMap
is
not
None
:
...
@@ -335,8 +335,8 @@ def _test():
...
@@ -335,8 +335,8 @@ def _test():
def
__getstate__
(
self
):
def
__getstate__
(
self
):
return
{
'a'
:
self
.
a
,
'arg'
:
self
.
arg
}
return
{
'a'
:
self
.
a
,
'arg'
:
self
.
arg
}
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
for
key
in
state
.
key
s
():
for
key
,
value
in
state
.
iteritem
s
():
setattr
(
self
,
key
,
state
[
key
]
)
setattr
(
self
,
key
,
value
)
def
__deepcopy__
(
self
,
memo
=
None
):
def
__deepcopy__
(
self
,
memo
=
None
):
new
=
self
.
__class__
(
deepcopy
(
self
.
arg
,
memo
))
new
=
self
.
__class__
(
deepcopy
(
self
.
arg
,
memo
))
new
.
a
=
self
.
a
new
.
a
=
self
.
a
...
...
Lib/filecmp.py
Dosyayı görüntüle @
e0d4972a
...
@@ -228,8 +228,8 @@ class dircmp:
...
@@ -228,8 +228,8 @@ class dircmp:
def
phase4_closure
(
self
):
# Recursively call phase4() on subdirectories
def
phase4_closure
(
self
):
# Recursively call phase4() on subdirectories
self
.
phase4
()
self
.
phase4
()
for
x
in
self
.
subdirs
.
key
s
():
for
sd
in
self
.
subdirs
.
itervalue
s
():
s
elf
.
subdirs
[
x
]
.
phase4_closure
()
s
d
.
phase4_closure
()
def
report
(
self
):
# Print a report on the differences between a and b
def
report
(
self
):
# Print a report on the differences between a and b
# Output format is purposely lousy
# Output format is purposely lousy
...
@@ -258,15 +258,15 @@ class dircmp:
...
@@ -258,15 +258,15 @@ class dircmp:
def
report_partial_closure
(
self
):
# Print reports on self and on subdirs
def
report_partial_closure
(
self
):
# Print reports on self and on subdirs
self
.
report
()
self
.
report
()
for
x
in
self
.
subdirs
.
key
s
():
for
sd
in
self
.
subdirs
.
itervalue
s
():
print
print
s
elf
.
subdirs
[
x
]
.
report
()
s
d
.
report
()
def
report_full_closure
(
self
):
# Report on self and subdirs recursively
def
report_full_closure
(
self
):
# Report on self and subdirs recursively
self
.
report
()
self
.
report
()
for
x
in
self
.
subdirs
.
key
s
():
for
sd
in
self
.
subdirs
.
itervalue
s
():
print
print
s
elf
.
subdirs
[
x
]
.
report_full_closure
()
s
d
.
report_full_closure
()
def
cmpfiles
(
a
,
b
,
common
,
shallow
=
1
,
use_statcache
=
0
):
def
cmpfiles
(
a
,
b
,
common
,
shallow
=
1
,
use_statcache
=
0
):
...
...
Lib/inspect.py
Dosyayı görüntüle @
e0d4972a
...
@@ -553,7 +553,7 @@ def getclasstree(classes, unique=0):
...
@@ -553,7 +553,7 @@ def getclasstree(classes, unique=0):
if
unique
and
parent
in
classes
:
break
if
unique
and
parent
in
classes
:
break
elif
c
not
in
roots
:
elif
c
not
in
roots
:
roots
.
append
(
c
)
roots
.
append
(
c
)
for
parent
in
children
.
keys
()
:
for
parent
in
children
:
if
parent
not
in
classes
:
if
parent
not
in
classes
:
roots
.
append
(
parent
)
roots
.
append
(
parent
)
return
walktree
(
roots
,
children
,
None
)
return
walktree
(
roots
,
children
,
None
)
...
...
Lib/mailcap.py
Dosyayı görüntüle @
e0d4972a
...
@@ -24,11 +24,11 @@ def getcaps():
...
@@ -24,11 +24,11 @@ def getcaps():
continue
continue
morecaps
=
readmailcapfile
(
fp
)
morecaps
=
readmailcapfile
(
fp
)
fp
.
close
()
fp
.
close
()
for
key
in
morecaps
.
key
s
():
for
key
,
value
in
morecaps
.
iteritem
s
():
if
not
key
in
caps
:
if
not
key
in
caps
:
caps
[
key
]
=
morecaps
[
key
]
caps
[
key
]
=
value
else
:
else
:
caps
[
key
]
=
caps
[
key
]
+
morecaps
[
key
]
caps
[
key
]
=
caps
[
key
]
+
value
return
caps
return
caps
def
listmailcapfiles
():
def
listmailcapfiles
():
...
...
Lib/profile.py
Dosyayı görüntüle @
e0d4972a
...
@@ -386,12 +386,11 @@ class Profile:
...
@@ -386,12 +386,11 @@ class Profile:
def
snapshot_stats
(
self
):
def
snapshot_stats
(
self
):
self
.
stats
=
{}
self
.
stats
=
{}
for
func
in
self
.
timings
.
keys
():
for
func
,
(
cc
,
ns
,
tt
,
ct
,
callers
)
in
self
.
timings
.
iteritems
():
cc
,
ns
,
tt
,
ct
,
callers
=
self
.
timings
[
func
]
callers
=
callers
.
copy
()
callers
=
callers
.
copy
()
nc
=
0
nc
=
0
for
func_caller
in
callers
.
key
s
():
for
callcnt
in
callers
.
itervalue
s
():
nc
=
nc
+
callers
[
func_caller
]
nc
+=
callcnt
self
.
stats
[
func
]
=
cc
,
nc
,
tt
,
ct
,
callers
self
.
stats
[
func
]
=
cc
,
nc
,
tt
,
ct
,
callers
...
...
Lib/pstats.py
Dosyayı görüntüle @
e0d4972a
...
@@ -142,7 +142,7 @@ class Stats:
...
@@ -142,7 +142,7 @@ class Stats:
self
.
total_calls
+=
other
.
total_calls
self
.
total_calls
+=
other
.
total_calls
self
.
prim_calls
+=
other
.
prim_calls
self
.
prim_calls
+=
other
.
prim_calls
self
.
total_tt
+=
other
.
total_tt
self
.
total_tt
+=
other
.
total_tt
for
func
in
other
.
top_level
.
keys
()
:
for
func
in
other
.
top_level
:
self
.
top_level
[
func
]
=
None
self
.
top_level
[
func
]
=
None
if
self
.
max_name_len
<
other
.
max_name_len
:
if
self
.
max_name_len
<
other
.
max_name_len
:
...
@@ -150,12 +150,12 @@ class Stats:
...
@@ -150,12 +150,12 @@ class Stats:
self
.
fcn_list
=
None
self
.
fcn_list
=
None
for
func
in
other
.
stats
.
key
s
():
for
func
,
stat
in
other
.
stats
.
iteritem
s
():
if
func
in
self
.
stats
:
if
func
in
self
.
stats
:
old_func_stat
=
self
.
stats
[
func
]
old_func_stat
=
self
.
stats
[
func
]
else
:
else
:
old_func_stat
=
(
0
,
0
,
0
,
0
,
{},)
old_func_stat
=
(
0
,
0
,
0
,
0
,
{},)
self
.
stats
[
func
]
=
add_func_stats
(
old_func_stat
,
other
.
stats
[
func
]
)
self
.
stats
[
func
]
=
add_func_stats
(
old_func_stat
,
stat
)
return
self
return
self
# list the tuple indices and directions for sorting,
# list the tuple indices and directions for sorting,
...
@@ -178,7 +178,7 @@ class Stats:
...
@@ -178,7 +178,7 @@ class Stats:
if
not
self
.
sort_arg_dict
:
if
not
self
.
sort_arg_dict
:
self
.
sort_arg_dict
=
dict
=
{}
self
.
sort_arg_dict
=
dict
=
{}
bad_list
=
{}
bad_list
=
{}
for
word
in
self
.
sort_arg_dict_default
.
key
s
():
for
word
,
tup
in
self
.
sort_arg_dict_default
.
iteritem
s
():
fragment
=
word
fragment
=
word
while
fragment
:
while
fragment
:
if
not
fragment
:
if
not
fragment
:
...
@@ -186,9 +186,9 @@ class Stats:
...
@@ -186,9 +186,9 @@ class Stats:
if
fragment
in
dict
:
if
fragment
in
dict
:
bad_list
[
fragment
]
=
0
bad_list
[
fragment
]
=
0
break
break
dict
[
fragment
]
=
self
.
sort_arg_dict_default
[
word
]
dict
[
fragment
]
=
tup
fragment
=
fragment
[:
-
1
]
fragment
=
fragment
[:
-
1
]
for
word
in
bad_list
.
keys
()
:
for
word
in
bad_list
:
del
dict
[
word
]
del
dict
[
word
]
return
self
.
sort_arg_dict
return
self
.
sort_arg_dict
...
@@ -213,8 +213,7 @@ class Stats:
...
@@ -213,8 +213,7 @@ class Stats:
connector
=
", "
connector
=
", "
stats_list
=
[]
stats_list
=
[]
for
func
in
self
.
stats
.
keys
():
for
func
,
(
cc
,
nc
,
tt
,
ct
,
callers
)
in
self
.
stats
.
iteritems
():
cc
,
nc
,
tt
,
ct
,
callers
=
self
.
stats
[
func
]
stats_list
.
append
((
cc
,
nc
,
tt
,
ct
)
+
func
+
stats_list
.
append
((
cc
,
nc
,
tt
,
ct
)
+
func
+
(
func_std_string
(
func
),
func
))
(
func_std_string
(
func
),
func
))
...
@@ -234,14 +233,13 @@ class Stats:
...
@@ -234,14 +233,13 @@ class Stats:
oldstats
=
self
.
stats
oldstats
=
self
.
stats
self
.
stats
=
newstats
=
{}
self
.
stats
=
newstats
=
{}
max_name_len
=
0
max_name_len
=
0
for
func
in
oldstats
.
keys
():
for
func
,
(
cc
,
nc
,
tt
,
ct
,
callers
)
in
oldstats
.
iteritems
():
cc
,
nc
,
tt
,
ct
,
callers
=
oldstats
[
func
]
newfunc
=
func_strip_path
(
func
)
newfunc
=
func_strip_path
(
func
)
if
len
(
func_std_string
(
newfunc
))
>
max_name_len
:
if
len
(
func_std_string
(
newfunc
))
>
max_name_len
:
max_name_len
=
len
(
func_std_string
(
newfunc
))
max_name_len
=
len
(
func_std_string
(
newfunc
))
newcallers
=
{}
newcallers
=
{}
for
func2
in
callers
.
key
s
():
for
func2
,
caller
in
callers
.
iteritem
s
():
newcallers
[
func_strip_path
(
func2
)]
=
caller
s
[
func2
]
newcallers
[
func_strip_path
(
func2
)]
=
caller
if
newfunc
in
newstats
:
if
newfunc
in
newstats
:
newstats
[
newfunc
]
=
add_func_stats
(
newstats
[
newfunc
]
=
add_func_stats
(
...
@@ -251,7 +249,7 @@ class Stats:
...
@@ -251,7 +249,7 @@ class Stats:
newstats
[
newfunc
]
=
(
cc
,
nc
,
tt
,
ct
,
newcallers
)
newstats
[
newfunc
]
=
(
cc
,
nc
,
tt
,
ct
,
newcallers
)
old_top
=
self
.
top_level
old_top
=
self
.
top_level
self
.
top_level
=
new_top
=
{}
self
.
top_level
=
new_top
=
{}
for
func
in
old_top
.
keys
()
:
for
func
in
old_top
:
new_top
[
func_strip_path
(
func
)]
=
None
new_top
[
func_strip_path
(
func
)]
=
None
self
.
max_name_len
=
max_name_len
self
.
max_name_len
=
max_name_len
...
@@ -263,14 +261,13 @@ class Stats:
...
@@ -263,14 +261,13 @@ class Stats:
def
calc_callees
(
self
):
def
calc_callees
(
self
):
if
self
.
all_callees
:
return
if
self
.
all_callees
:
return
self
.
all_callees
=
all_callees
=
{}
self
.
all_callees
=
all_callees
=
{}
for
func
in
self
.
stats
.
key
s
():
for
func
,
(
cc
,
nc
,
tt
,
ct
,
callers
)
in
self
.
stats
.
iteritem
s
():
if
not
func
in
all_callees
:
if
not
func
in
all_callees
:
all_callees
[
func
]
=
{}
all_callees
[
func
]
=
{}
cc
,
nc
,
tt
,
ct
,
callers
=
self
.
stats
[
func
]
for
func2
,
caller
in
callers
.
iteritems
():
for
func2
in
callers
.
keys
():
if
not
func2
in
all_callees
:
if
not
func2
in
all_callees
:
all_callees
[
func2
]
=
{}
all_callees
[
func2
]
=
{}
all_callees
[
func2
][
func
]
=
caller
s
[
func2
]
all_callees
[
func2
][
func
]
=
caller
return
return
#******************************************************************
#******************************************************************
...
@@ -330,7 +327,7 @@ class Stats:
...
@@ -330,7 +327,7 @@ class Stats:
print
filename
print
filename
if
self
.
files
:
print
if
self
.
files
:
print
indent
=
' '
*
8
indent
=
' '
*
8
for
func
in
self
.
top_level
.
keys
()
:
for
func
in
self
.
top_level
:
print
indent
,
func_get_function_name
(
func
)
print
indent
,
func_get_function_name
(
func
)
print
indent
,
self
.
total_calls
,
"function calls"
,
print
indent
,
self
.
total_calls
,
"function calls"
,
...
@@ -468,20 +465,20 @@ def add_func_stats(target, source):
...
@@ -468,20 +465,20 @@ def add_func_stats(target, source):
def
add_callers
(
target
,
source
):
def
add_callers
(
target
,
source
):
"""Combine two caller lists in a single list."""
"""Combine two caller lists in a single list."""
new_callers
=
{}
new_callers
=
{}
for
func
in
target
.
key
s
():
for
func
,
caller
in
target
.
iteritem
s
():
new_callers
[
func
]
=
target
[
func
]
new_callers
[
func
]
=
caller
for
func
in
source
.
key
s
():
for
func
,
caller
in
source
.
iteritem
s
():
if
func
in
new_callers
:
if
func
in
new_callers
:
new_callers
[
func
]
=
source
[
func
]
+
new_callers
[
func
]
new_callers
[
func
]
=
caller
+
new_callers
[
func
]
else
:
else
:
new_callers
[
func
]
=
source
[
func
]
new_callers
[
func
]
=
caller
return
new_callers
return
new_callers
def
count_calls
(
callers
):
def
count_calls
(
callers
):
"""Sum the caller statistics to get total number of calls received."""
"""Sum the caller statistics to get total number of calls received."""
nc
=
0
nc
=
0
for
func
in
callers
.
key
s
():
for
calls
in
callers
.
itervalue
s
():
nc
+=
call
ers
[
func
]
nc
+=
call
s
return
nc
return
nc
#**************************************************************************
#**************************************************************************
...
@@ -595,19 +592,19 @@ if __name__ == '__main__':
...
@@ -595,19 +592,19 @@ if __name__ == '__main__':
print
"Reverse the sort order of the profiling report."
print
"Reverse the sort order of the profiling report."
def
do_sort
(
self
,
line
):
def
do_sort
(
self
,
line
):
abbrevs
=
self
.
stats
.
get_sort_arg_defs
()
.
keys
()
abbrevs
=
self
.
stats
.
get_sort_arg_defs
()
if
line
and
not
filter
(
lambda
x
,
a
=
abbrevs
:
x
not
in
a
,
line
.
split
()):
if
line
and
not
filter
(
lambda
x
,
a
=
abbrevs
:
x
not
in
a
,
line
.
split
()):
apply
(
self
.
stats
.
sort_stats
,
line
.
split
())
apply
(
self
.
stats
.
sort_stats
,
line
.
split
())
else
:
else
:
print
"Valid sort keys (unique prefixes are accepted):"
print
"Valid sort keys (unique prefixes are accepted):"
for
(
key
,
value
)
in
Stats
.
sort_arg_dict_default
.
items
():
for
(
key
,
value
)
in
Stats
.
sort_arg_dict_default
.
ite
rite
ms
():
print
"
%
s --
%
s"
%
(
key
,
value
[
1
])
print
"
%
s --
%
s"
%
(
key
,
value
[
1
])
return
0
return
0
def
help_sort
(
self
):
def
help_sort
(
self
):
print
"Sort profile data according to specified keys."
print
"Sort profile data according to specified keys."
print
"(Typing `sort' without arguments lists valid keys.)"
print
"(Typing `sort' without arguments lists valid keys.)"
def
complete_sort
(
self
,
text
,
*
args
):
def
complete_sort
(
self
,
text
,
*
args
):
return
[
a
for
a
in
Stats
.
sort_arg_dict_default
.
keys
()
if
a
.
startswith
(
text
)]
return
[
a
for
a
in
Stats
.
sort_arg_dict_default
if
a
.
startswith
(
text
)]
def
do_stats
(
self
,
line
):
def
do_stats
(
self
,
line
):
return
self
.
generic
(
'print_stats'
,
line
)
return
self
.
generic
(
'print_stats'
,
line
)
...
...
Lib/pyclbr.py
Dosyayı görüntüle @
e0d4972a
...
@@ -324,7 +324,7 @@ def readmodule_ex(module, path=[], inpackage=0):
...
@@ -324,7 +324,7 @@ def readmodule_ex(module, path=[], inpackage=0):
# Python does internally)
# Python does internally)
# also don't add names that
# also don't add names that
# start with _
# start with _
for
n
in
d
.
keys
()
:
for
n
in
d
:
if
n
[
0
]
!=
'_'
and
\
if
n
[
0
]
!=
'_'
and
\
not
n
in
dict
:
not
n
in
dict
:
dict
[
n
]
=
d
[
n
]
dict
[
n
]
=
d
[
n
]
...
...
Lib/rlcompleter.py
Dosyayı görüntüle @
e0d4972a
...
@@ -104,8 +104,8 @@ class Completer:
...
@@ -104,8 +104,8 @@ class Completer:
matches
=
[]
matches
=
[]
n
=
len
(
text
)
n
=
len
(
text
)
for
list
in
[
keyword
.
kwlist
,
for
list
in
[
keyword
.
kwlist
,
__builtin__
.
__dict__
.
keys
()
,
__builtin__
.
__dict__
,
self
.
namespace
.
keys
()
]:
self
.
namespace
]:
for
word
in
list
:
for
word
in
list
:
if
word
[:
n
]
==
text
and
word
!=
"__builtins__"
:
if
word
[:
n
]
==
text
and
word
!=
"__builtins__"
:
matches
.
append
(
word
)
matches
.
append
(
word
)
...
...
Lib/symtable.py
Dosyayı görüntüle @
e0d4972a
...
@@ -163,7 +163,7 @@ class Class(SymbolTable):
...
@@ -163,7 +163,7 @@ class Class(SymbolTable):
d
=
{}
d
=
{}
for
st
in
self
.
_table
.
children
:
for
st
in
self
.
_table
.
children
:
d
[
st
.
name
]
=
1
d
[
st
.
name
]
=
1
self
.
__methods
=
tuple
(
d
.
keys
()
)
self
.
__methods
=
tuple
(
d
)
return
self
.
__methods
return
self
.
__methods
class
Symbol
:
class
Symbol
:
...
...
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