Skip to content

Commit 5caf252

Browse files
committed
Use memoryview for count_level_2d
1 parent 6bcd303 commit 5caf252

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pandas/_libs/lib.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,16 +981,14 @@ def get_level_sorter(
981981

982982
@cython.boundscheck(False)
983983
@cython.wraparound(False)
984-
def count_level_2d(ndarray[uint8_t, ndim=2, cast=True] mask,
984+
def count_level_2d(const uint8_t[:, :] mask,
985985
const intp_t[:] labels,
986986
Py_ssize_t max_bin,
987987
):
988988
cdef:
989-
Py_ssize_t i, j, k, n
989+
Py_ssize_t i, j, k = mask.shape[1], n = mask.shape[0]
990990
ndarray[int64_t, ndim=2] counts
991991

992-
n, k = (<object>mask).shape
993-
994992
counts = np.zeros((n, max_bin), dtype="i8")
995993
with nogil:
996994
for i in range(n):

0 commit comments

Comments
 (0)