Skip to content

Commit f0b8a8f

Browse files
committed
Address code review
1 parent 0637d48 commit f0b8a8f

File tree

7 files changed

+12
-32
lines changed

7 files changed

+12
-32
lines changed

Include/internal/pycore_list.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ extern "C" {
1010

1111
PyAPI_FUNC(PyObject*) _PyList_Extend(PyListObject *, PyObject *);
1212
extern void _PyList_DebugMallocStats(FILE *out);
13-
extern PyObject* _PyList_GetItemRef(PyObject *, Py_ssize_t i);
13+
// _PyList_GetItemRef should be used only when the object is known to be a list.
14+
extern PyObject* _PyList_GetItemRef(PyListObject *, Py_ssize_t i);
1415

1516
#define _PyList_ITEMS(op) _Py_RVALUE(_PyList_CAST(op)->ob_item)
1617

Lib/test/test_dis.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,27 +1260,6 @@ def test_super_instructions(self):
12601260
got = self.get_disassembly(load_test, adaptive=True)
12611261
self.do_disassembly_compare(got, dis_load_test_quickened_code)
12621262

1263-
@cpython_only
1264-
@requires_specialization
1265-
def test_binary_subscr_specialize(self):
1266-
binary_subscr_quicken = """\
1267-
0 RESUME_CHECK 0
1268-
1269-
1 LOAD_NAME 0 (a)
1270-
LOAD_SMALL_INT 0
1271-
%s
1272-
RETURN_VALUE
1273-
"""
1274-
co_list = compile('a[0]', "<list>", "eval")
1275-
self.code_quicken(lambda: exec(co_list, {}, {'a': [0]}))
1276-
got = self.get_disassembly(co_list, adaptive=True)
1277-
self.do_disassembly_compare(got, binary_subscr_quicken % "BINARY_SUBSCR_LIST_INT")
1278-
1279-
co_dict = compile('a[0]', "<dict>", "eval")
1280-
self.code_quicken(lambda: exec(co_dict, {}, {'a': {0: '1'}}))
1281-
got = self.get_disassembly(co_dict, adaptive=True)
1282-
self.do_disassembly_compare(got, binary_subscr_quicken % "BINARY_SUBSCR_DICT")
1283-
12841263
@cpython_only
12851264
@requires_specialization
12861265
def test_load_attr_specialize(self):

Lib/test/test_opcache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ def write(items):
617617
opname = "BINARY_SUBSCR_GETITEM"
618618
self.assert_races_do_not_crash(opname, get_items, read, write)
619619

620-
@requires_specialization
620+
@requires_specialization_ft
621621
def test_binary_subscr_list_int(self):
622622
def get_items():
623623
items = []
@@ -1023,7 +1023,7 @@ def write(items):
10231023
opname = "STORE_ATTR_WITH_HINT"
10241024
self.assert_races_do_not_crash(opname, get_items, read, write)
10251025

1026-
@requires_specialization
1026+
@requires_specialization_ft
10271027
def test_store_subscr_list_int(self):
10281028
def get_items():
10291029
items = []

Objects/listobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ PyList_GetItemRef(PyObject *op, Py_ssize_t i)
392392
}
393393

394394
PyObject *
395-
_PyList_GetItemRef(PyObject *op, Py_ssize_t i)
395+
_PyList_GetItemRef(PyListObject *list, Py_ssize_t i)
396396
{
397-
return list_get_item_ref((PyListObject *)op, i);
397+
return list_get_item_ref(list, i);
398398
}
399399

400400
int

Python/bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ dummy_func(
791791
DEOPT_IF(!_PyLong_IsNonNegativeCompact((PyLongObject *)sub));
792792
Py_ssize_t index = ((PyLongObject*)sub)->long_value.ob_digit[0];
793793
#ifdef Py_GIL_DISABLED
794-
STAT_INC(BINARY_SUBSCR, hit);
795-
PyObject *res_o = _PyList_GetItemRef(list, index);
794+
PyObject *res_o = _PyList_GetItemRef((PyListObject*)list, index);
796795
DEOPT_IF(res_o == NULL);
796+
STAT_INC(BINARY_SUBSCR, hit);
797797
#else
798798
DEOPT_IF(index >= PyList_GET_SIZE(list));
799799
STAT_INC(BINARY_SUBSCR, hit);

Python/executor_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)