Closed superbobry closed 8 years ago
LGTM, though the reason for imin2/imax2 was because those are fast inlined versions that avoid the overhead of the python min
and max
functions. Since those aren't in tight loops, I guess simplicity is preferable here.
I've checked the code generated by Cython. The line
cdef int lm = max(0, n - (N - K))
is translated to
__pyx_t_1 = (__pyx_v_n - (__pyx_v_N - __pyx_v_K));
__pyx_t_2 = 0;
if (((__pyx_t_1 > __pyx_t_2) != 0)) {
__pyx_t_3 = __pyx_t_1;
} else {
__pyx_t_3 = __pyx_t_2;
}
__pyx_v_lm = __pyx_t_3;
Similarly for min
.
sweet! thanks