Skip to content

Commit fee3937

Browse files
Compute result and use rich compare
1 parent 2a92ba9 commit fee3937

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

Python/optimizer_bytecodes.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,17 @@ dummy_func(void) {
451451
{
452452
assert(PyLong_CheckExact(sym_get_const(ctx, left)));
453453
assert(PyLong_CheckExact(sym_get_const(ctx, right)));
454+
PyObject *tmp = PyObject_RichCompare(sym_get_const(ctx, left),
455+
sym_get_const(ctx, right),
456+
oparg >> 5);
457+
if (tmp == NULL) {
458+
goto error;
459+
}
460+
res = sym_new_const(ctx, tmp);
461+
Py_DECREF(tmp);
454462

455463
if (_Py_IsImmortal(res)) {
456-
REPLACE_OP(this_instr, _POP_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)true);
464+
REPLACE_OP(this_instr, _POP_TWO_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)tmp);
457465
}
458466
else {
459467
res = sym_new_type(ctx, &PyBool_Type);

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)