diff options
Diffstat (limited to 'Cython/Utility/MatchCase_Cy.pyx')
-rw-r--r-- | Cython/Utility/MatchCase_Cy.pyx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Cython/Utility/MatchCase_Cy.pyx b/Cython/Utility/MatchCase_Cy.pyx new file mode 100644 index 000000000..dbb478ffe --- /dev/null +++ b/Cython/Utility/MatchCase_Cy.pyx @@ -0,0 +1,12 @@ +################### MemoryviewSliceToList ####################### + +cimport cython + +@cname("__Pyx_MatchCase_SliceMemoryview_{{suffix}}") +cdef list slice_to_list({{decl_code}} x, Py_ssize_t start, Py_ssize_t stop): + if stop < 0: + # use -1 as a flag for "end" + stop = x.shape[0] + # This code performs slightly better than [ xi for xi in x ] + with cython.boundscheck(False), cython.wraparound(False): + return [ x[i] for i in range(start, stop) ] |