Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply the same technique for compactlong_float
  • Loading branch information
Eclips4 committed Jan 18, 2025
commit f98667c8a540a181e364f44beebf6683f7eb7fc3
14 changes: 5 additions & 9 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)

// Guards should check that the float part is not NaN.
// Guards for / (aka true_div) should check for 0 or 0.0 as the rhs.
static int
static inline int
float_compactlong_guard(PyObject *lhs, PyObject *rhs)
{
return (
Expand All @@ -2429,7 +2429,7 @@ float_compactlong_guard(PyObject *lhs, PyObject *rhs)
);
}

static int
static inline int
float_compactlong_guard_true_div(PyObject *lhs, PyObject *rhs)
Comment thread
Eclips4 marked this conversation as resolved.
Outdated
{
return (
Expand All @@ -2453,7 +2453,7 @@ FLOAT_LONG_ACTION(float_compactlong_true_div, /)

/* long-float */

static int
static inline int
compactlong_float_guard(PyObject *lhs, PyObject *rhs)
{
return (
Expand All @@ -2464,15 +2464,11 @@ compactlong_float_guard(PyObject *lhs, PyObject *rhs)
);
}

static int
static inline int
compactlong_float_guard_true_div(PyObject *lhs, PyObject *rhs)
{
return (
PyFloat_CheckExact(rhs) &&
PyLong_CheckExact(lhs) &&
_PyLong_IsCompact((PyLongObject *)lhs) &&
PyFloat_AsDouble(rhs) != 0.0 &&
!isnan(PyFloat_AsDouble(rhs))
compactlong_float_guard(lhs, rhs) && PyFloat_AsDouble(rhs) != 0.0
);
}

Expand Down