@@ -3770,28 +3770,29 @@ isna_element(PyObject *m, PyObject *args, PyObject *kwargs)
3770
3770
}
3771
3771
// Try to identify Pandas Timestamp NATs
3772
3772
if (PyObject_HasAttrString (element , "to_numpy" )) {
3773
- // can we match the class name NaTType?
3774
-
3775
- PyObject * to_numpy = PyObject_GetAttrString (element , "to_numpy" );
3776
- if (to_numpy == NULL ) {
3777
- return NULL ;
3778
- }
3779
- if (!PyCallable_Check (to_numpy )) {
3780
- Py_DECREF (to_numpy );
3781
- Py_RETURN_FALSE ;
3782
- }
3783
- PyObject * scalar = PyObject_CallFunction (to_numpy , NULL );
3784
- Py_DECREF (to_numpy );
3785
- if (scalar == NULL ) {
3786
- return NULL ;
3787
- }
3788
- if (!PyArray_IsScalar (scalar , Datetime )) {
3789
- Py_DECREF (scalar );
3790
- Py_RETURN_FALSE ;
3791
- }
3792
- PyObject * pb = PyBool_FromLong (PyArrayScalar_VAL (scalar , Datetime ) == NPY_DATETIME_NAT );
3793
- Py_DECREF (scalar );
3794
- return pb ;
3773
+ // strcmp returns 0 on match
3774
+ return PyBool_FromLong (strcmp (element -> ob_type -> tp_name , "NaTType" ) == 0 );
3775
+ // the long way
3776
+ // PyObject *to_numpy = PyObject_GetAttrString(element, "to_numpy");
3777
+ // if (to_numpy == NULL) {
3778
+ // return NULL;
3779
+ // }
3780
+ // if (!PyCallable_Check(to_numpy)) {
3781
+ // Py_DECREF(to_numpy);
3782
+ // Py_RETURN_FALSE;
3783
+ // }
3784
+ // PyObject* scalar = PyObject_CallFunction(to_numpy, NULL);
3785
+ // Py_DECREF(to_numpy);
3786
+ // if (scalar == NULL) {
3787
+ // return NULL;
3788
+ // }
3789
+ // if (!PyArray_IsScalar(scalar, Datetime)) {
3790
+ // Py_DECREF(scalar);
3791
+ // Py_RETURN_FALSE;
3792
+ // }
3793
+ // PyObject* pb = PyBool_FromLong(PyArrayScalar_VAL(scalar, Datetime) == NPY_DATETIME_NAT);
3794
+ // Py_DECREF(scalar);
3795
+ // return pb;
3795
3796
}
3796
3797
Py_RETURN_FALSE ;
3797
3798
}
0 commit comments