Skip to content

Commit 957674b

Browse files
committed
perf(specialize): widen BINARY_OP_ADD_INT specialization to int64 range
Change the add specialization condition from _PyLong_CheckExactAndCompact to _PyLong_CheckExactAndFitsInt64 so that exact int operands in the full int64 range (not just compact/single-digit values) are specialized to BINARY_OP_ADD_INT. Subtract and multiply retain their compact-only conditions.
1 parent 7a3ab4b commit 957674b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Python/specialize.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
23502350
specialize(instr, BINARY_OP_ADD_UNICODE);
23512351
return;
23522352
}
2353-
if (_PyLong_CheckExactAndCompact(lhs) && _PyLong_CheckExactAndCompact(rhs)) {
2353+
if (_PyLong_CheckExactAndFitsInt64(lhs) && _PyLong_CheckExactAndFitsInt64(rhs)) {
23542354
specialize(instr, BINARY_OP_ADD_INT);
23552355
return;
23562356
}

0 commit comments

Comments
 (0)