Skip to content

Commit 5037f97

Browse files
authored
Merge branch 'main' into upsate-http-servers
2 parents 95821d1 + 684001f commit 5037f97

File tree

143 files changed

+9229
-2118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+9229
-2118
lines changed

.cspell.dict/cpython.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ CLASSDEREF
3333
classdict
3434
cmpop
3535
codedepth
36-
constevaluator
3736
CODEUNIT
3837
CONIN
3938
CONOUT
39+
constevaluator
4040
CONVFUNC
4141
convparam
4242
copyslot
@@ -62,6 +62,7 @@ fieldlist
6262
fileutils
6363
finalbody
6464
finalizers
65+
firsttraceable
6566
flowgraph
6667
formatfloat
6768
freevar

Lib/opcode.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -46,75 +46,6 @@
4646
hascompare = [opmap["COMPARE_OP"]]
4747

4848
_cache_format = {
49-
"LOAD_GLOBAL": {
50-
"counter": 1,
51-
"index": 1,
52-
"module_keys_version": 1,
53-
"builtin_keys_version": 1,
54-
},
55-
"BINARY_OP": {
56-
"counter": 1,
57-
"descr": 4,
58-
},
59-
"UNPACK_SEQUENCE": {
60-
"counter": 1,
61-
},
62-
"COMPARE_OP": {
63-
"counter": 1,
64-
},
65-
"CONTAINS_OP": {
66-
"counter": 1,
67-
},
68-
"FOR_ITER": {
69-
"counter": 1,
70-
},
71-
"LOAD_SUPER_ATTR": {
72-
"counter": 1,
73-
},
74-
"LOAD_ATTR": {
75-
"counter": 1,
76-
"version": 2,
77-
"keys_version": 2,
78-
"descr": 4,
79-
},
80-
"STORE_ATTR": {
81-
"counter": 1,
82-
"version": 2,
83-
"index": 1,
84-
},
85-
"CALL": {
86-
"counter": 1,
87-
"func_version": 2,
88-
},
89-
"CALL_KW": {
90-
"counter": 1,
91-
"func_version": 2,
92-
},
93-
"STORE_SUBSCR": {
94-
"counter": 1,
95-
},
96-
"SEND": {
97-
"counter": 1,
98-
},
99-
"JUMP_BACKWARD": {
100-
"counter": 1,
101-
},
102-
"TO_BOOL": {
103-
"counter": 1,
104-
"version": 2,
105-
},
106-
"POP_JUMP_IF_TRUE": {
107-
"counter": 1,
108-
},
109-
"POP_JUMP_IF_FALSE": {
110-
"counter": 1,
111-
},
112-
"POP_JUMP_IF_NONE": {
113-
"counter": 1,
114-
},
115-
"POP_JUMP_IF_NOT_NONE": {
116-
"counter": 1,
117-
},
11849
}
11950

12051
_inline_cache_entries = {

Lib/test/dis_module.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# A simple module for testing the dis module.
3+
4+
def f(): pass
5+
def g(): pass

Lib/test/profilee.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
"""
2+
Input for test_profile.py and test_cprofile.py.
3+
4+
IMPORTANT: This stuff is touchy. If you modify anything above the
5+
test class you'll have to regenerate the stats by running the two
6+
test files.
7+
8+
*ALL* NUMBERS in the expected output are relevant. If you change
9+
the formatting of pstats, please don't just regenerate the expected
10+
output without checking very carefully that not a single number has
11+
changed.
12+
"""
13+
14+
import sys
15+
16+
# In order to have reproducible time, we simulate a timer in the global
17+
# variable 'TICKS', which represents simulated time in milliseconds.
18+
# (We can't use a helper function increment the timer since it would be
19+
# included in the profile and would appear to consume all the time.)
20+
TICKS = 42000
21+
22+
def timer():
23+
return TICKS
24+
25+
def testfunc():
26+
# 1 call
27+
# 1000 ticks total: 270 ticks local, 730 ticks in subfunctions
28+
global TICKS
29+
TICKS += 99
30+
helper() # 300
31+
helper() # 300
32+
TICKS += 171
33+
factorial(14) # 130
34+
35+
def factorial(n):
36+
# 23 calls total
37+
# 170 ticks total, 150 ticks local
38+
# 3 primitive calls, 130, 20 and 20 ticks total
39+
# including 116, 17, 17 ticks local
40+
global TICKS
41+
if n > 0:
42+
TICKS += n
43+
return mul(n, factorial(n-1))
44+
else:
45+
TICKS += 11
46+
return 1
47+
48+
def mul(a, b):
49+
# 20 calls
50+
# 1 tick, local
51+
global TICKS
52+
TICKS += 1
53+
return a * b
54+
55+
def helper():
56+
# 2 calls
57+
# 300 ticks total: 20 ticks local, 260 ticks in subfunctions
58+
global TICKS
59+
TICKS += 1
60+
helper1() # 30
61+
TICKS += 2
62+
helper1() # 30
63+
TICKS += 6
64+
helper2() # 50
65+
TICKS += 3
66+
helper2() # 50
67+
TICKS += 2
68+
helper2() # 50
69+
TICKS += 5
70+
helper2_indirect() # 70
71+
TICKS += 1
72+
73+
def helper1():
74+
# 4 calls
75+
# 30 ticks total: 29 ticks local, 1 tick in subfunctions
76+
global TICKS
77+
TICKS += 10
78+
hasattr(C(), "foo") # 1
79+
TICKS += 19
80+
lst = []
81+
lst.append(42) # 0
82+
sys.exception() # 0
83+
84+
def helper2_indirect():
85+
helper2() # 50
86+
factorial(3) # 20
87+
88+
def helper2():
89+
# 8 calls
90+
# 50 ticks local: 39 ticks local, 11 ticks in subfunctions
91+
global TICKS
92+
TICKS += 11
93+
hasattr(C(), "bar") # 1
94+
TICKS += 13
95+
subhelper() # 10
96+
TICKS += 15
97+
98+
def subhelper():
99+
# 8 calls
100+
# 10 ticks total: 8 ticks local, 2 ticks in subfunctions
101+
global TICKS
102+
TICKS += 2
103+
for i in range(2): # 0
104+
try:
105+
C().foo # 1 x 2
106+
except AttributeError:
107+
TICKS += 3 # 3 x 2
108+
109+
class C:
110+
def __getattr__(self, name):
111+
# 28 calls
112+
# 1 tick, local
113+
global TICKS
114+
TICKS += 1
115+
raise AttributeError

0 commit comments

Comments
 (0)