@@ -988,13 +988,17 @@ def delta_to_tick(delta: timedelta) -> Tick:
988
988
# --------------------------------------------------------------------
989
989
990
990
991
- class BusinessMixin(SingleConstructorOffset ):
991
+ cdef class BusinessMixin(SingleConstructorOffset ):
992
992
"""
993
993
Mixin to business types to provide related functions.
994
994
"""
995
+
996
+ cdef readonly:
997
+ timedelta _offset
998
+
995
999
def __init__ (self , n = 1 , normalize = False , offset = timedelta(0 )):
996
1000
BaseOffset.__init__ (self , n, normalize)
997
- object . __setattr__ ( self , " _offset" , offset)
1001
+ self . _offset = offset
998
1002
999
1003
@property
1000
1004
def offset (self ):
@@ -1014,6 +1018,11 @@ class BusinessMixin(SingleConstructorOffset):
1014
1018
out += ": " + ", ".join(attrs )
1015
1019
return out
1016
1020
1021
+ cpdef __setstate__(self , state ):
1022
+ # We need to use a cdef/cpdef method to set the readonly _offset attribute
1023
+ BaseOffset.__setstate__(self , state)
1024
+ self ._offset = state[" _offset" ]
1025
+
1017
1026
1018
1027
class BusinessHourMixin (BusinessMixin ):
1019
1028
_adjust_dst = False
@@ -1067,6 +1076,9 @@ class BusinessHourMixin(BusinessMixin):
1067
1076
object .__setattr__ (self , " start" , start)
1068
1077
object .__setattr__ (self , " end" , end)
1069
1078
1079
+ def __reduce__ (self ):
1080
+ return type (self ), (self .n, self .normalize, self .start, self .end, self .offset)
1081
+
1070
1082
def _repr_attrs (self ) -> str:
1071
1083
out = super ()._repr_attrs()
1072
1084
hours = " ," .join(
0 commit comments