Skip to content

Commit f18ac8d

Browse files
committed
Use more const memoryviews
1 parent 5caf252 commit f18ac8d

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

pandas/_libs/internals.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def get_concat_blkno_indexers(list blknos_list not None):
502502
@cython.boundscheck(False)
503503
@cython.wraparound(False)
504504
def get_blkno_indexers(
505-
int64_t[:] blknos, bint group=True
505+
const int64_t[:] blknos, bint group=True
506506
) -> list[tuple[int, slice | np.ndarray]]:
507507
"""
508508
Enumerate contiguous runs of integers in ndarray.
@@ -596,8 +596,8 @@ def get_blkno_placements(blknos, group: bool = True):
596596
@cython.boundscheck(False)
597597
@cython.wraparound(False)
598598
cpdef update_blklocs_and_blknos(
599-
ndarray[intp_t, ndim=1] blklocs,
600-
ndarray[intp_t, ndim=1] blknos,
599+
const intp_t[:] blklocs,
600+
const intp_t[:] blknos,
601601
Py_ssize_t loc,
602602
intp_t nblocks,
603603
):

pandas/_libs/join.pyx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ def full_outer_join(const intp_t[:] left, const intp_t[:] right,
225225

226226
@cython.wraparound(False)
227227
@cython.boundscheck(False)
228-
cdef void _get_result_indexer(intp_t[::1] sorter, intp_t[::1] indexer) noexcept nogil:
228+
cdef void _get_result_indexer(
229+
const intp_t[::1] sorter,
230+
intp_t[::1] indexer,
231+
) noexcept nogil:
229232
"""NOTE: overwrites indexer with the result to avoid allocating another array"""
230233
cdef:
231234
Py_ssize_t i, n, idx
@@ -681,8 +684,8 @@ def outer_join_indexer(ndarray[numeric_object_t] left, ndarray[numeric_object_t]
681684
from pandas._libs.hashtable cimport Int64HashTable
682685

683686

684-
def asof_join_backward_on_X_by_Y(ndarray[numeric_t] left_values,
685-
ndarray[numeric_t] right_values,
687+
def asof_join_backward_on_X_by_Y(const numeric_t[:] left_values,
688+
const numeric_t[:] right_values,
686689
const int64_t[:] left_by_values,
687690
const int64_t[:] right_by_values,
688691
bint allow_exact_matches=True,
@@ -752,8 +755,8 @@ def asof_join_backward_on_X_by_Y(ndarray[numeric_t] left_values,
752755
return left_indexer, right_indexer
753756

754757

755-
def asof_join_forward_on_X_by_Y(ndarray[numeric_t] left_values,
756-
ndarray[numeric_t] right_values,
758+
def asof_join_forward_on_X_by_Y(const numeric_t[:] left_values,
759+
const numeric_t[:] right_values,
757760
const int64_t[:] left_by_values,
758761
const int64_t[:] right_by_values,
759762
bint allow_exact_matches=1,
@@ -824,8 +827,8 @@ def asof_join_forward_on_X_by_Y(ndarray[numeric_t] left_values,
824827
return left_indexer, right_indexer
825828

826829

827-
def asof_join_nearest_on_X_by_Y(ndarray[numeric_t] left_values,
828-
ndarray[numeric_t] right_values,
830+
def asof_join_nearest_on_X_by_Y(const numeric_t[:] left_values,
831+
const numeric_t[:] right_values,
829832
const int64_t[:] left_by_values,
830833
const int64_t[:] right_by_values,
831834
bint allow_exact_matches=True,

0 commit comments

Comments
 (0)