buffer_entry.generate_buffer_slice_code(code, self.original_indices,
self.result(),
have_gil=have_gil,
- have_slices=have_slices)
+ have_slices=have_slices,
+ directives=code.globalstate.directives)
def generate_memoryviewslice_setslice_code(self, rhs, code):
"memslice1[...] = memslice2 or memslice1[:] = memslice2"
return bufp
def generate_buffer_slice_code(self, code, indices, dst, have_gil,
- have_slices):
+ have_slices, directives):
"""
Slice a memoryviewslice.
"All preceding dimensions must be "
"indexed and not sliced")
+ wraparound = int(directives['wraparound'])
+ boundscheck = int(directives['boundscheck'])
d = locals()
code.put(load_slice_util("SliceIndex", d))
Py_ssize_t __pyx_tmp_idx = {{idx}};
Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}];
Py_ssize_t __pyx_tmp_stride = {{src}}.strides[{{dim}}];
- if (__pyx_tmp_idx < 0)
+ if ({{wraparound}} && (__pyx_tmp_idx < 0))
__pyx_tmp_idx += __pyx_tmp_shape;
- if (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape) {
+ if ({{boundscheck}} && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
{{if not have_gil}}
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();