@@ -55,6 +55,8 @@ from datetime cimport (
55
55
from datetime import time as datetime_time
56
56
57
57
from tslibs.np_datetime cimport (check_dts_bounds,
58
+ reverse_ops,
59
+ cmp_scalar,
58
60
pandas_datetimestruct,
59
61
dt64_to_dtstruct, dtstruct_to_dt64,
60
62
pydatetime_to_dt64, pydate_to_dt64)
@@ -893,31 +895,6 @@ def unique_deltas(ndarray[int64_t] arr):
893
895
return result
894
896
895
897
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
-
921
898
cdef str _NDIM_STRING = " ndim"
922
899
923
900
# This is PITA. Because we inherit from datetime, which has very specific
@@ -970,7 +947,7 @@ cdef class _Timestamp(datetime):
970
947
raise TypeError (' Cannot compare type %r with type %r ' %
971
948
(type (self ).__name__,
972
949
type (other).__name__))
973
- return PyObject_RichCompare(other, self , _reverse_ops [op])
950
+ return PyObject_RichCompare(other, self , reverse_ops [op])
974
951
else :
975
952
if op == Py_EQ:
976
953
return False
@@ -980,7 +957,7 @@ cdef class _Timestamp(datetime):
980
957
(type (self ).__name__, type (other).__name__))
981
958
982
959
self ._assert_tzawareness_compat(other)
983
- return _cmp_scalar (self .value, ots.value, op)
960
+ return cmp_scalar (self .value, ots.value, op)
984
961
985
962
def __reduce_ex__ (self , protocol ):
986
963
# python 3.6 compat
@@ -2066,7 +2043,7 @@ cdef class _Timedelta(timedelta):
2066
2043
type (other).__name__))
2067
2044
if util.is_array(other):
2068
2045
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])
2070
2047
else :
2071
2048
if op == Py_EQ:
2072
2049
return False
@@ -2075,7 +2052,7 @@ cdef class _Timedelta(timedelta):
2075
2052
raise TypeError (' Cannot compare type %r with type %r ' %
2076
2053
(type (self ).__name__, type (other).__name__))
2077
2054
2078
- return _cmp_scalar (self .value, ots.value, op)
2055
+ return cmp_scalar (self .value, ots.value, op)
2079
2056
2080
2057
def _ensure_components (_Timedelta self ):
2081
2058
"""
0 commit comments