Skip to content

Commit f20331d

Browse files
authored
Added const where avaible (#32893)
* Added `const` where avaible * Trying to use memoryviews REF: https://github.com/pandas-dev/pandas/pull/32893/files#r396033598 * Nitpick, added a trailing comma Co-authored-by: MomIsBestFriend <>
1 parent d3e5485 commit f20331d

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

pandas/_libs/tslibs/conversion.pyx

+8-4
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,12 @@ cdef inline void localize_tso(_TSObject obj, tzinfo tz):
595595
obj.tzinfo = tz
596596

597597

598-
cdef inline bint _infer_tsobject_fold(_TSObject obj, ndarray[int64_t] trans,
599-
int64_t[:] deltas, int32_t pos):
598+
cdef inline bint _infer_tsobject_fold(
599+
_TSObject obj,
600+
const int64_t[:] trans,
601+
const int64_t[:] deltas,
602+
int32_t pos,
603+
):
600604
"""
601605
Infer _TSObject fold property from value by assuming 0 and then setting
602606
to 1 if necessary.
@@ -738,7 +742,7 @@ def normalize_i8_timestamps(int64_t[:] stamps, object tz):
738742

739743
@cython.wraparound(False)
740744
@cython.boundscheck(False)
741-
cdef int64_t[:] _normalize_local(int64_t[:] stamps, tzinfo tz):
745+
cdef int64_t[:] _normalize_local(const int64_t[:] stamps, tzinfo tz):
742746
"""
743747
Normalize each of the (nanosecond) timestamps in the given array by
744748
rounding down to the beginning of the day (i.e. midnight) for the
@@ -818,7 +822,7 @@ cdef inline int64_t _normalized_stamp(npy_datetimestruct *dts) nogil:
818822

819823
@cython.wraparound(False)
820824
@cython.boundscheck(False)
821-
def is_date_array_normalized(int64_t[:] stamps, object tz=None):
825+
def is_date_array_normalized(const int64_t[:] stamps, object tz=None):
822826
"""
823827
Check if all of the given (nanosecond) timestamps are normalized to
824828
midnight, i.e. hour == minute == second == 0. If the optional timezone

pandas/_libs/tslibs/offsets.pyx

+8-3
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,13 @@ cdef inline int month_add_months(npy_datetimestruct dts, int months) nogil:
609609

610610
@cython.wraparound(False)
611611
@cython.boundscheck(False)
612-
def shift_quarters(int64_t[:] dtindex, int quarters,
613-
int q1start_month, object day, int modby=3):
612+
def shift_quarters(
613+
const int64_t[:] dtindex,
614+
int quarters,
615+
int q1start_month,
616+
object day,
617+
int modby=3,
618+
):
614619
"""
615620
Given an int64 array representing nanosecond timestamps, shift all elements
616621
by the specified number of quarters using DateOffset semantics.
@@ -759,7 +764,7 @@ def shift_quarters(int64_t[:] dtindex, int quarters,
759764

760765
@cython.wraparound(False)
761766
@cython.boundscheck(False)
762-
def shift_months(int64_t[:] dtindex, int months, object day=None):
767+
def shift_months(const int64_t[:] dtindex, int months, object day=None):
763768
"""
764769
Given an int64-based datetime index, shift all elements
765770
specified number of months using DateOffset semantics

pandas/_libs/tslibs/timedeltas.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ _no_input = object()
101101

102102
@cython.boundscheck(False)
103103
@cython.wraparound(False)
104-
def ints_to_pytimedelta(int64_t[:] arr, box=False):
104+
def ints_to_pytimedelta(const int64_t[:] arr, box=False):
105105
"""
106106
convert an i8 repr to an ndarray of timedelta or Timedelta (if box ==
107107
True)

pandas/_libs/tslibs/tzconversion.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,9 @@ cdef int64_t _tz_convert_tzlocal_fromutc(int64_t val, tzinfo tz, bint *fold):
549549

550550
@cython.boundscheck(False)
551551
@cython.wraparound(False)
552-
cdef int64_t[:] _tz_convert_dst(int64_t[:] values, tzinfo tz,
553-
bint to_utc=True):
552+
cdef int64_t[:] _tz_convert_dst(
553+
const int64_t[:] values, tzinfo tz, bint to_utc=True,
554+
):
554555
"""
555556
tz_convert for non-UTC non-tzlocal cases where we have to check
556557
DST transitions pointwise.

0 commit comments

Comments
 (0)