@@ -55,6 +55,8 @@ from datetime cimport (
5555from datetime import time as datetime_time
5656
5757from tslibs.np_datetime cimport (check_dts_bounds,
58+ reverse_ops,
59+ cmp_scalar,
5860 pandas_datetimestruct,
5961 dt64_to_dtstruct, dtstruct_to_dt64,
6062 pydatetime_to_dt64, pydate_to_dt64)
@@ -893,31 +895,6 @@ def unique_deltas(ndarray[int64_t] arr):
893895 return result
894896
895897
896- cdef inline bint _cmp_scalar(int64_t lhs, int64_t rhs, int op) except - 1 :
897- if op == Py_EQ:
898- return lhs == rhs
899- elif op == Py_NE:
900- return lhs != rhs
901- elif op == Py_LT:
902- return lhs < rhs
903- elif op == Py_LE:
904- return lhs <= rhs
905- elif op == Py_GT:
906- return lhs > rhs
907- elif op == Py_GE:
908- return lhs >= rhs
909-
910-
911- cdef int _reverse_ops[6 ]
912-
913- _reverse_ops[Py_LT] = Py_GT
914- _reverse_ops[Py_LE] = Py_GE
915- _reverse_ops[Py_EQ] = Py_EQ
916- _reverse_ops[Py_NE] = Py_NE
917- _reverse_ops[Py_GT] = Py_LT
918- _reverse_ops[Py_GE] = Py_LE
919-
920-
921898cdef str _NDIM_STRING = " ndim"
922899
923900# This is PITA. Because we inherit from datetime, which has very specific
@@ -970,7 +947,7 @@ cdef class _Timestamp(datetime):
970947 raise TypeError (' Cannot compare type %r with type %r ' %
971948 (type (self ).__name__,
972949 type (other).__name__))
973- return PyObject_RichCompare(other, self , _reverse_ops [op])
950+ return PyObject_RichCompare(other, self , reverse_ops [op])
974951 else :
975952 if op == Py_EQ:
976953 return False
@@ -980,7 +957,7 @@ cdef class _Timestamp(datetime):
980957 (type (self ).__name__, type (other).__name__))
981958
982959 self ._assert_tzawareness_compat(other)
983- return _cmp_scalar (self .value, ots.value, op)
960+ return cmp_scalar (self .value, ots.value, op)
984961
985962 def __reduce_ex__ (self , protocol ):
986963 # python 3.6 compat
@@ -2066,7 +2043,7 @@ cdef class _Timedelta(timedelta):
20662043 type (other).__name__))
20672044 if util.is_array(other):
20682045 return PyObject_RichCompare(np.array([self ]), other, op)
2069- return PyObject_RichCompare(other, self , _reverse_ops [op])
2046+ return PyObject_RichCompare(other, self , reverse_ops [op])
20702047 else :
20712048 if op == Py_EQ:
20722049 return False
@@ -2075,7 +2052,7 @@ cdef class _Timedelta(timedelta):
20752052 raise TypeError (' Cannot compare type %r with type %r ' %
20762053 (type (self ).__name__, type (other).__name__))
20772054
2078- return _cmp_scalar (self .value, ots.value, op)
2055+ return cmp_scalar (self .value, ots.value, op)
20792056
20802057 def _ensure_components (_Timedelta self ):
20812058 """
0 commit comments