@@ -25,10 +25,6 @@ from cpython cimport (
2525)
2626
2727
28- cdef extern from " headers/stdint.h" :
29- enum : INT64_MAX
30- enum : INT64_MIN
31-
3228# Cython < 0.17 doesn't have this in cpython
3329cdef extern from " Python.h" :
3430 cdef PyTypeObject * Py_TYPE(object )
@@ -42,7 +38,7 @@ from datetime cimport cmp_pandas_datetimestruct
4238from libc.stdlib cimport free
4339
4440from util cimport (is_integer_object, is_float_object, is_datetime64_object,
45- is_timedelta64_object)
41+ is_timedelta64_object, INT64_MAX )
4642cimport util
4743
4844from datetime cimport *
@@ -909,9 +905,12 @@ cpdef object get_value_box(ndarray arr, object loc):
909905
910906
911907# Add the min and max fields at the class level
912- # INT64_MIN is reserved for NaT
913- cdef int64_t _NS_LOWER_BOUND = INT64_MIN + 1
914908cdef int64_t _NS_UPPER_BOUND = INT64_MAX
909+ # smallest value we could actually represent is
910+ # INT64_MIN + 1 == -9223372036854775807
911+ # but to allow overflow free conversion with a microsecond resolution
912+ # use the smallest value with a 0 nanosecond unit
913+ cdef int64_t _NS_LOWER_BOUND = - 9223285636854775000L L
915914
916915cdef pandas_datetimestruct _NS_MIN_DTS, _NS_MAX_DTS
917916pandas_datetime_to_datetimestruct(_NS_LOWER_BOUND, PANDAS_FR_ns, & _NS_MIN_DTS)
0 commit comments