Skip to content

Commit

Permalink
CLN: Use more memoryviews (pandas-dev#58330)
Browse files Browse the repository at this point in the history
* Add memoryviews in reshape.pyx

* Use more const memoryviews
  • Loading branch information
mroeschke committed Apr 22, 2024
1 parent 22e5247 commit 3461db5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def has_infs(const floating[:] arr) -> bool:

@cython.boundscheck(False)
@cython.wraparound(False)
def has_only_ints_or_nan(floating[:] arr) -> bool:
def has_only_ints_or_nan(const floating[:] arr) -> bool:
cdef:
floating val
intp_t i
Expand Down Expand Up @@ -631,7 +631,7 @@ ctypedef fused int6432_t:

@cython.wraparound(False)
@cython.boundscheck(False)
def is_range_indexer(ndarray[int6432_t, ndim=1] left, Py_ssize_t n) -> bool:
def is_range_indexer(const int6432_t[:] left, Py_ssize_t n) -> bool:
"""
Perform an element by element comparison on 1-d integer arrays, meant for indexer
comparisons
Expand All @@ -652,7 +652,7 @@ def is_range_indexer(ndarray[int6432_t, ndim=1] left, Py_ssize_t n) -> bool:

@cython.wraparound(False)
@cython.boundscheck(False)
def is_sequence_range(ndarray[int6432_t, ndim=1] sequence, int64_t step) -> bool:
def is_sequence_range(const int6432_t[:] sequence, int64_t step) -> bool:
"""
Check if sequence is equivalent to a range with the specified step.
"""
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/reshape.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ from pandas._libs.lib cimport c_is_list_like

@cython.wraparound(False)
@cython.boundscheck(False)
def unstack(numeric_object_t[:, :] values, const uint8_t[:] mask,
def unstack(const numeric_object_t[:, :] values, const uint8_t[:] mask,
Py_ssize_t stride, Py_ssize_t length, Py_ssize_t width,
numeric_object_t[:, :] new_values, uint8_t[:, :] new_mask) -> None:
"""
Expand Down Expand Up @@ -80,7 +80,7 @@ def unstack(numeric_object_t[:, :] values, const uint8_t[:] mask,

@cython.wraparound(False)
@cython.boundscheck(False)
def explode(ndarray[object] values):
def explode(object[:] values):
"""
transform array list-likes to long form
preserve non-list entries
Expand Down

0 comments on commit 3461db5

Please sign in to comment.