Skip to content

Speed up checking for NaN for floats #25946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2019
Merged
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
8 changes: 6 additions & 2 deletions pandas/_libs/tslibs/util.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cdef extern from "Python.h":
const char* PyUnicode_AsUTF8AndSize(object obj,
Py_ssize_t* length) except NULL

from numpy cimport int64_t
from numpy cimport int64_t, float64_t

cdef extern from "numpy/arrayobject.h":
PyTypeObject PyFloatingArrType_Type
Expand Down Expand Up @@ -215,7 +215,11 @@ cdef inline bint is_nan(object val):
-------
is_nan : bool
"""
return (is_float_object(val) or is_complex_object(val)) and val != val
cdef float64_t fval
if is_float_object(val):
fval = val
return fval != fval
return is_complex_object(val) and val != val


cdef inline const char* get_c_string_buf_and_size(object py_string,
Expand Down