diff options
author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2006-05-25 15:53:30 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2006-05-25 15:53:30 (GMT) |
commit | f94323fbb4e83b756b1f328f06a1615d8c366c20 (patch) | |
tree | 0162fcea03d1e3ba5aeec93b1cff612dd19c01d7 /Objects/floatobject.c | |
parent | 4b4e33ef14cecd0bc9c6566ea8b402733e7e445f (diff) | |
download | cpython-f94323fbb4e83b756b1f328f06a1615d8c366c20.zip cpython-f94323fbb4e83b756b1f328f06a1615d8c366c20.tar.gz cpython-f94323fbb4e83b756b1f328f06a1615d8c366c20.tar.bz2 |
Added a new macro, Py_IS_FINITE(X). On windows there is an intrinsic for this and it is more efficient than to use !Py_IS_INFINITE(X) && !Py_IS_NAN(X). No change on other platforms
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 7650ae6..fa09084 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -384,7 +384,7 @@ float_richcompare(PyObject *v, PyObject *w, int op) if (PyFloat_Check(w)) j = PyFloat_AS_DOUBLE(w); - else if (Py_IS_INFINITY(i) || Py_IS_NAN(i)) { + else if (!Py_IS_FINITE(i)) { if (PyInt_Check(w) || PyLong_Check(w)) /* If i is an infinity, its magnitude exceeds any * finite integer, so it doesn't matter which int we @@ -802,10 +802,7 @@ float_pow(PyObject *v, PyObject *w, PyObject *z) * bug; we let that slide in math.pow() (which currently * reflects all platform accidents), but not for Python's **. */ - if (iv == -1.0 && !Py_IS_INFINITY(iw) && iw == iw) { - /* XXX the "iw == iw" was to weed out NaNs. This - * XXX doesn't actually work on all platforms. - */ + if (iv == -1.0 && Py_IS_FINITE(iw)) { /* Return 1 if iw is even, -1 if iw is odd; there's * no guarantee that any C integral type is big * enough to hold iw, so we have to check this |