Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9e88ff

Browse filesBrowse files
authored
gh-131798: Use sym_new_type instead of sym_new_not_null for _BUILD_LIST, _BUILD_SLICE, and _BUILD_MAP (GH-132434)
--------- Signed-off-by: Manjusaka <me@manjusaka.me>
1 parent 62ff86f commit b9e88ff
Copy full SHA for b9e88ff

File tree

Expand file treeCollapse file tree

4 files changed

+21
-7
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+21
-7
lines changed

‎Lib/test/test_capi/test_opt.py

Copy file name to clipboardExpand all lines: Lib/test/test_capi/test_opt.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,15 +1678,15 @@ def f(n):
16781678
x = 0
16791679
for _ in range(n):
16801680
d = {}
1681-
d["Spam"] = 1 # Guarded...
1681+
d["Spam"] = 1 # unguarded!
16821682
x += d["Spam"] # ...unguarded!
16831683
return x
16841684

16851685
res, ex = self._run_with_optimizer(f, TIER2_THRESHOLD)
16861686
self.assertEqual(res, TIER2_THRESHOLD)
16871687
self.assertIsNotNone(ex)
16881688
uops = get_opnames(ex)
1689-
self.assertEqual(uops.count("_GUARD_NOS_DICT"), 1)
1689+
self.assertEqual(uops.count("_GUARD_NOS_DICT"), 0)
16901690
self.assertEqual(uops.count("_STORE_SUBSCR_DICT"), 1)
16911691
self.assertEqual(uops.count("_BINARY_OP_SUBSCR_DICT"), 1)
16921692

@@ -1695,7 +1695,7 @@ def f(n):
16951695
x = 0
16961696
for _ in range(n):
16971697
l = [0]
1698-
l[0] = 1 # Guarded...
1698+
l[0] = 1 # unguarded!
16991699
[a] = l # ...unguarded!
17001700
b = l[0] # ...unguarded!
17011701
if l: # ...unguarded!
@@ -1706,7 +1706,7 @@ def f(n):
17061706
self.assertEqual(res, 2 * TIER2_THRESHOLD)
17071707
self.assertIsNotNone(ex)
17081708
uops = get_opnames(ex)
1709-
self.assertEqual(uops.count("_GUARD_NOS_LIST"), 1)
1709+
self.assertEqual(uops.count("_GUARD_NOS_LIST"), 0)
17101710
self.assertEqual(uops.count("_STORE_SUBSCR_LIST_INT"), 1)
17111711
self.assertEqual(uops.count("_GUARD_TOS_LIST"), 0)
17121712
self.assertEqual(uops.count("_UNPACK_SEQUENCE_LIST"), 1)
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Use ``sym_new_type`` instead of ``sym_new_not_null`` for _BUILD_LIST,
2+
_BUILD_SET, _BUILD_MAP

‎Python/optimizer_bytecodes.c

Copy file name to clipboardExpand all lines: Python/optimizer_bytecodes.c
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,18 @@ dummy_func(void) {
919919
tup = sym_new_tuple(ctx, oparg, values);
920920
}
921921

922+
op(_BUILD_LIST, (values[oparg] -- list)) {
923+
list = sym_new_type(ctx, &PyList_Type);
924+
}
925+
926+
op(_BUILD_SLICE, (values[oparg] -- slice)) {
927+
slice = sym_new_type(ctx, &PySlice_Type);
928+
}
929+
930+
op(_BUILD_MAP, (values[oparg*2] -- map)) {
931+
map = sym_new_type(ctx, &PyDict_Type);
932+
}
933+
922934
op(_UNPACK_SEQUENCE_TWO_TUPLE, (seq -- val1, val0)) {
923935
val0 = sym_tuple_getitem(ctx, seq, 0);
924936
val1 = sym_tuple_getitem(ctx, seq, 1);

‎Python/optimizer_cases.c.h

Copy file name to clipboardExpand all lines: Python/optimizer_cases.c.h
+3-3Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.