pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/pull/144826/files

="https://github.githubassets.com/assets/primer-primitives-10bf9dd67e3d70bd.css" /> gh-100239: use PyFloat_AS_DOUBLE and _PyLong_IsZero in the float / compactlong specializations by chris-eibl · Pull Request #144826 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Speedup ``BINARY_OP_EXTEND`` for exact floats and medium-size integers by up
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compact ints are an implementation detail and the term medium-size integers has been chosen in news entries in the past for them.

to 15%. Patch by Chris Eibl.
12 changes: 6 additions & 6 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ float_compactlong_guard(PyObject *lhs, PyObject *rhs)
{
return (
PyFloat_CheckExact(lhs) &&
!isnan(PyFloat_AsDouble(lhs)) &&
!isnan(PyFloat_AS_DOUBLE(lhs)) &&
PyLong_CheckExact(rhs) &&
_PyLong_IsCompact((PyLongObject *)rhs)
);
Expand All @@ -2110,15 +2110,15 @@ static inline int
nonzero_float_compactlong_guard(PyObject *lhs, PyObject *rhs)
{
return (
float_compactlong_guard(lhs, rhs) && !PyLong_IsZero(rhs)
float_compactlong_guard(lhs, rhs) && !_PyLong_IsZero((PyLongObject*)rhs)
);
}

#define FLOAT_LONG_ACTION(NAME, OP) \
static PyObject * \
(NAME)(PyObject *lhs, PyObject *rhs) \
{ \
double lhs_val = PyFloat_AsDouble(lhs); \
double lhs_val = PyFloat_AS_DOUBLE(lhs); \
Py_ssize_t rhs_val = _PyLong_CompactValue((PyLongObject *)rhs); \
return PyFloat_FromDouble(lhs_val OP rhs_val); \
}
Expand All @@ -2137,23 +2137,23 @@ compactlong_float_guard(PyObject *lhs, PyObject *rhs)
PyLong_CheckExact(lhs) &&
_PyLong_IsCompact((PyLongObject *)lhs) &&
PyFloat_CheckExact(rhs) &&
!isnan(PyFloat_AsDouble(rhs))
!isnan(PyFloat_AS_DOUBLE(rhs))
);
}

static inline int
nonzero_compactlong_float_guard(PyObject *lhs, PyObject *rhs)
{
return (
compactlong_float_guard(lhs, rhs) && PyFloat_AsDouble(rhs) != 0.0
compactlong_float_guard(lhs, rhs) && PyFloat_AS_DOUBLE(rhs) != 0.0
);
}

#define LONG_FLOAT_ACTION(NAME, OP) \
static PyObject * \
(NAME)(PyObject *lhs, PyObject *rhs) \
{ \
double rhs_val = PyFloat_AsDouble(rhs); \
double rhs_val = PyFloat_AS_DOUBLE(rhs); \
Py_ssize_t lhs_val = _PyLong_CompactValue((PyLongObject *)lhs); \
return PyFloat_FromDouble(lhs_val OP rhs_val); \
}
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy