diff --git a/pandas/_libs/tslibs/offsets.pxd b/pandas/_libs/tslibs/offsets.pxd index 69b878c77f0b8..2b8ad97b83917 100644 --- a/pandas/_libs/tslibs/offsets.pxd +++ b/pandas/_libs/tslibs/offsets.pxd @@ -1,3 +1,11 @@ +from numpy cimport int64_t + cpdef to_offset(object obj) cdef bint is_offset_object(object obj) cdef bint is_tick_object(object obj) + +cdef class BaseOffset: + cdef readonly: + int64_t n + bint normalize + dict _cache diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 9e6a2c0507f7f..33b478c4d8da4 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -366,10 +366,10 @@ cdef class BaseOffset: _adjust_dst = True _deprecations = frozenset(["isAnchored", "onOffset"]) - cdef readonly: - int64_t n - bint normalize - dict _cache + # cdef readonly: + # int64_t n + # bint normalize + # dict _cache def __init__(self, n=1, normalize=False): n = self._validate_n(n) diff --git a/pandas/_libs/tslibs/period.pyx b/pandas/_libs/tslibs/period.pyx index bc190825214c1..30c5dd1a881ea 100644 --- a/pandas/_libs/tslibs/period.pyx +++ b/pandas/_libs/tslibs/period.pyx @@ -69,7 +69,10 @@ from pandas._libs.tslibs.nattype cimport ( c_nat_strings as nat_strings, ) from pandas._libs.tslibs.offsets cimport ( - to_offset, is_tick_object, is_offset_object, + BaseOffset, + to_offset, + is_tick_object, + is_offset_object, ) from pandas._libs.tslibs.tzconversion cimport tz_convert_utc_to_tzlocal @@ -1509,9 +1512,9 @@ cdef class _Period: cdef readonly: int64_t ordinal - object freq + BaseOffset freq - def __cinit__(self, ordinal, freq): + def __cinit__(self, int64_t ordinal, BaseOffset freq): self.ordinal = ordinal self.freq = freq diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index f7f8b86359732..10c1a56a2eb4e 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1205,7 +1205,7 @@ class Timedelta(_Timedelta): cdef: int64_t result, unit - from pandas.tseries.frequencies import to_offset + from pandas._libs.tslibs.offsets import to_offset unit = to_offset(freq).nanos result = unit * rounder(self.value / float(unit)) return Timedelta(result, unit='ns')